Skip to content

Commit

Permalink
feat: add hotkey to close all tabs (#2800)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan1xk committed Aug 14, 2024
1 parent 1bedfc2 commit 3b8909e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/bruno-app/src/providers/Hotkeys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,31 @@ export const HotkeysProvider = (props) => {
};
}, [activeTabUid]);

// close all tabs
useEffect(() => {
Mousetrap.bind(['command+shift+w', 'ctrl+shift+w'], (e) => {
const activeTab = find(tabs, (t) => t.uid === activeTabUid);
if (activeTab) {
const collection = findCollectionByUid(collections, activeTab.collectionUid);

if (collection) {
const tabUids = tabs.filter((tab) => tab.collectionUid === collection.uid).map((tab) => tab.uid);
dispatch(
closeTabs({
tabUids: tabUids
})
);
}
}

return false; // this stops the event bubbling
});

return () => {
Mousetrap.unbind(['command+shift+w', 'ctrl+shift+w']);
};
}, [activeTabUid, tabs, collections, dispatch]);

return (
<HotkeysContext.Provider {...props} value="hotkey">
{showSaveRequestModal && (
Expand Down

0 comments on commit 3b8909e

Please sign in to comment.