(null);
const layouts = useMemo(
() =>
@@ -289,6 +313,13 @@ export function Sidebar() {
}
}, [location.pathname, setSidebarOpen]);
+ // Keep the active page visible in the sidebar after any navigation
+ // (e.g. from the command palette or an external link).
+ useEffect(() => {
+ const active = navRef.current?.querySelector('[data-sidebar-active="true"]');
+ active?.scrollIntoView({ block: 'nearest' });
+ }, [location.pathname, activeSection]);
+
if (!sidebarOpen || !schema) return null;
const layout: Layout | undefined = layouts.find((l) => l.name === activeSection);
@@ -312,7 +343,7 @@ export function Sidebar() {
/>