feat: shortcut for expand/collapse of sidebar (#1797)

Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
Aditya Sharma 2023-04-04 03:09:45 +05:30 committed by GitHub
parent b1618e9ce1
commit cd089ed64a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,6 +86,18 @@ export const WorkSpaceSliderBar: React.FC<WorkSpaceSliderBarProps> = ({
useEffect(() => {
window.apis?.onSidebarVisibilityChange(sidebarOpen);
}, [sidebarOpen]);
useEffect(() => {
const keydown = (e: KeyboardEvent) => {
if ((e.key === '/' && e.metaKey) || (e.key === '/' && e.ctrlKey)) {
setSidebarOpen(!sidebarOpen);
}
};
document.addEventListener('keydown', keydown, { capture: true });
return () =>
document.removeEventListener('keydown', keydown, { capture: true });
}, [sidebarOpen, setSidebarOpen]);
return (
<>
<StyledSliderBarWrapper