Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

Aditya Sharmacd089ed64a69
diff --git a/apps/web/src/components/pure/workspace-slider-bar/index.tsx b/apps/web/src/components/pure/workspace-slider-bar/index.tsx
index a6081db388..2b99c7f366 100644
--- a/apps/web/src/components/pure/workspace-slider-bar/index.tsx
+++ b/apps/web/src/components/pure/workspace-slider-bar/index.tsx
@@ -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