Skip to content

Commit 7c7de97

Browse files
CopilotOmgRod
andcommitted
fix: open sidebar section when navigating to a page in a closed category
Co-authored-by: OmgRod <89850217+OmgRod@users.noreply.github.com> Agent-Logs-Url: https://github.com/OmgRod/MiniWiki/sessions/0604eae2-be0e-4eb2-9c59-486ee33f494a
1 parent 81d5d22 commit 7c7de97

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)