mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-29 11:23:57 +01:00
Proposed addition of CMD+W hotkey Re #128
This commit is contained in:
parent
2120a562da
commit
8c29d131e2
@ -10,6 +10,7 @@ import NewRequest from 'components/Sidebar/NewRequest';
|
|||||||
import BrunoSupport from 'components/BrunoSupport';
|
import BrunoSupport from 'components/BrunoSupport';
|
||||||
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import { findCollectionByUid, findItemInCollection } from 'utils/collections';
|
import { findCollectionByUid, findItemInCollection } from 'utils/collections';
|
||||||
|
import { closeTabs } from 'providers/ReduxStore/slices/tabs';
|
||||||
|
|
||||||
export const HotkeysContext = React.createContext();
|
export const HotkeysContext = React.createContext();
|
||||||
|
|
||||||
@ -144,6 +145,23 @@ export const HotkeysProvider = (props) => {
|
|||||||
};
|
};
|
||||||
}, [setShowNewRequestModal]);
|
}, [setShowNewRequestModal]);
|
||||||
|
|
||||||
|
// close tab hotkey
|
||||||
|
useEffect(() => {
|
||||||
|
Mousetrap.bind(['command+w', 'ctrl+w'], (e) => {
|
||||||
|
dispatch(
|
||||||
|
closeTabs({
|
||||||
|
tabUids: [activeTabUid]
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
return false; // this stops the event bubbling
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
Mousetrap.unbind(['command+w', 'ctrl+w']);
|
||||||
|
};
|
||||||
|
}, [activeTabUid, tabs, collections, setShowNewRequestModal]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HotkeysContext.Provider {...props} value="hotkey">
|
<HotkeysContext.Provider {...props} value="hotkey">
|
||||||
{showBrunoSupportModal && <BrunoSupport onClose={() => setShowBrunoSupportModal(false)} />}
|
{showBrunoSupportModal && <BrunoSupport onClose={() => setShowBrunoSupportModal(false)} />}
|
||||||
|
Loading…
Reference in New Issue
Block a user