diff --git a/apps/web/src/components/cached-router/index.tsx b/apps/web/src/components/cached-router/index.tsx index 1b062825b..4293ceb38 100644 --- a/apps/web/src/components/cached-router/index.tsx +++ b/apps/web/src/components/cached-router/index.tsx @@ -80,4 +80,4 @@ function CachedRouter() { ); } -export default React.memo(CachedRouter, () => true); +export default React.memo(CachedRouter); diff --git a/apps/web/src/components/navigation-menu/index.tsx b/apps/web/src/components/navigation-menu/index.tsx index d43e7cc15..aaf7f8020 100644 --- a/apps/web/src/components/navigation-menu/index.tsx +++ b/apps/web/src/components/navigation-menu/index.tsx @@ -54,7 +54,8 @@ import { getCurrentPath, hardNavigate, hashNavigate, - navigate + navigate, + NavigationEvents } from "../../navigation"; import { db } from "../../common/db"; import { isMobile } from "../../hooks/use-mobile"; @@ -205,10 +206,22 @@ function NavigationMenu({ onExpand }: { onExpand?: () => void }) { if (isNavPaneCollapsed) setExpanded(false); }, [isNavPaneCollapsed]); + useEffect(() => { + // collapse navigation menu on navigate e.g. when navigating to a notebook + // or a tag + function onNavigate() { + if (!useAppStore.getState().isNavPaneCollapsed) return; + setExpanded(false); + } + const event = NavigationEvents.subscribe("onNavigate", onNavigate); + return () => { + event.unsubscribe(); + }; + }, []); + return (