Skip to content

Commit 52efbc8

Browse files
authored
Merge pull request #13 from OmgRod/copilot/fix-sidebar-visibility-update
Fix sidebar categories not opening on client-side navigation
2 parents b591db9 + 7c7de97 commit 52efbc8

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

components/Sidebar.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Link from 'next/link';
2-
import { useMemo, useState } from 'react';
2+
import { useEffect, useMemo, useState } from 'react';
33

44
function SidebarSection({ section, currentPath }) {
55
const initialOpen = useMemo(() => {
@@ -11,6 +11,13 @@ function SidebarSection({ section, currentPath }) {
1111
}, [section, currentPath]);
1212

1313
const [isOpen, setIsOpen] = useState(initialOpen);
14+
15+
useEffect(() => {
16+
if (initialOpen) {
17+
setIsOpen(true);
18+
}
19+
}, [initialOpen]);
20+
1421
const collapsible = section.collapsible !== false;
1522

1623
return (

0 commit comments

Comments
 (0)