From 3b8909e301a4ad24db134c8cb1b5bd47561514ff Mon Sep 17 00:00:00 2001 From: Daniel Roberto Date: Wed, 14 Aug 2024 07:13:32 -0300 Subject: [PATCH] feat: add hotkey to close all tabs (#2800) --- .../bruno-app/src/providers/Hotkeys/index.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/bruno-app/src/providers/Hotkeys/index.js b/packages/bruno-app/src/providers/Hotkeys/index.js index 8b0503b1cf..53a0fc263c 100644 --- a/packages/bruno-app/src/providers/Hotkeys/index.js +++ b/packages/bruno-app/src/providers/Hotkeys/index.js @@ -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 ( {showSaveRequestModal && (