fix(admin): collapse inactive sidebar sections by default and fix toggle logic

This commit is contained in:
2026-04-22 19:10:17 -04:00
parent fa43e2c034
commit 35cfa8b51a
2 changed files with 17 additions and 8 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
# Claude Code Rules # 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.
+16 -7
View File
@@ -23,17 +23,26 @@ function resolveIcon(iconNameOrComponent) {
const AdminSidebar = ({ isMobileMenuOpen, setIsMobileMenuOpen, appName, enabledModules, navigationSections: serverNavigationSections }) => { const AdminSidebar = ({ isMobileMenuOpen, setIsMobileMenuOpen, appName, enabledModules, navigationSections: serverNavigationSections }) => {
const pathname = usePathname(); 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) => { const toggleSection = (sectionId) => {
setCollapsedSections(prev => { setCollapsedSections(prev => {
const newCollapsed = new Set(prev); const next = new Set(prev);
if (newCollapsed.has(sectionId)) { if (next.has(sectionId)) {
newCollapsed.delete(sectionId); next.delete(sectionId);
} else { } 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); const isActive = isSectionActive(section);
return ( return (