mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-22 20:51:23 +01:00
feat: improved tab behaviour while closing a tab
This commit is contained in:
parent
d49eb4df33
commit
6bb3967379
@ -49,14 +49,24 @@ export const tabsSlice = createSlice({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeTabs: (state, action) => {
|
closeTabs: (state, action) => {
|
||||||
|
const activeTab = find(state.tabs, (t) => t.uid === state.activeTabUid);
|
||||||
const tabUids = action.payload.tabUids || [];
|
const tabUids = action.payload.tabUids || [];
|
||||||
state.tabs = filter(state.tabs, (t) => !tabUids.includes(t.uid));
|
state.tabs = filter(state.tabs, (t) => !tabUids.includes(t.uid));
|
||||||
|
|
||||||
if(state.tabs && state.tabs.length) {
|
if(activeTab && state.tabs.length) {
|
||||||
// todo: closing tab needs to focus on the right adjacent tab
|
const { collectionUid } = activeTab;
|
||||||
state.activeTabUid = last(state.tabs).uid;
|
const activeTabStillExists = find(state.tabs, (t) => t.uid === state.activeTabUid);
|
||||||
} else {
|
|
||||||
state.activeTabUid = null;
|
if(!activeTabStillExists) {
|
||||||
|
// attempt to load sibling tabs (based on collections) of the dead tab
|
||||||
|
const siblingTabs = filter(state.tabs, (t) => t.collectionUid === collectionUid);
|
||||||
|
|
||||||
|
if(siblingTabs && siblingTabs.length) {
|
||||||
|
state.activeTabUid = last(siblingTabs).uid;
|
||||||
|
} else {
|
||||||
|
state.activeTabUid = last(state.tabs).uid;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// todo: implement this
|
// todo: implement this
|
||||||
|
Loading…
Reference in New Issue
Block a user