diff --git a/CLAUDE.md b/CLAUDE.md index acd3da6..254d0e9 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,3 +1,3 @@ # Claude Code Rules -Always read [docs/DEV.md](docs/DEV.md) at the start of every conversation before doing any work in this project. +Always read and respect [docs/DEV.md](docs/DEV.md) at the start of every conversation before doing any work in this project. diff --git a/src/features/admin/components/AdminSidebar.js b/src/features/admin/components/AdminSidebar.js index 9902e7e..4c296a2 100644 --- a/src/features/admin/components/AdminSidebar.js +++ b/src/features/admin/components/AdminSidebar.js @@ -23,17 +23,26 @@ function resolveIcon(iconNameOrComponent) { const AdminSidebar = ({ isMobileMenuOpen, setIsMobileMenuOpen, appName, enabledModules, navigationSections: serverNavigationSections }) => { const pathname = usePathname(); - const [collapsedSections, setCollapsedSections] = useState(new Set()); + const [collapsedSections, setCollapsedSections] = useState(() => { + const initial = new Set(); + serverNavigationSections.forEach(section => { + const isActive = section.items.some(item => + pathname === item.href || pathname.startsWith(item.href + '/') + ); + if (!isActive) initial.add(section.id); + }); + return initial; + }); const toggleSection = (sectionId) => { setCollapsedSections(prev => { - const newCollapsed = new Set(prev); - if (newCollapsed.has(sectionId)) { - newCollapsed.delete(sectionId); + const next = new Set(prev); + if (next.has(sectionId)) { + next.delete(sectionId); } else { - newCollapsed.add(sectionId); + next.add(sectionId); } - return newCollapsed; + return next; }); }; @@ -105,7 +114,7 @@ const AdminSidebar = ({ isMobileMenuOpen, setIsMobileMenuOpen, appName, enabledM ); } - const isCollapsed = !collapsedSections.has(section.id) && !isSectionActive(section); + const isCollapsed = collapsedSections.has(section.id) && !isSectionActive(section); const isActive = isSectionActive(section); return (