From 05bdac6ee004d93f4b98f23a8bad1815af1cc29e Mon Sep 17 00:00:00 2001 From: maulanasdqn Date: Sat, 11 Apr 2026 20:39:17 +0700 Subject: [PATCH] fix: auto-expand sidebar group containing current route on page load --- .../backoffice-sidebar/backoffice-sidebar.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/ui/src/organisms/backoffice-sidebar/backoffice-sidebar.tsx b/libs/ui/src/organisms/backoffice-sidebar/backoffice-sidebar.tsx index ef0b498..0480412 100644 --- a/libs/ui/src/organisms/backoffice-sidebar/backoffice-sidebar.tsx +++ b/libs/ui/src/organisms/backoffice-sidebar/backoffice-sidebar.tsx @@ -164,7 +164,15 @@ export const BackofficeSidebar: FC = ({ }): ReactElement => { const { signOut } = useSession(); const location = useLocation(); - const [openGroups, setOpenGroups] = useState>({}); + const [openGroups, setOpenGroups] = useState>(() => { + const initial: Record = {}; + MENUS.forEach((menu) => { + if (menu.children?.some((child) => child.href && location.pathname.includes(child.href))) { + initial[menu.label] = true; + } + }); + return initial; + }); const isActive = (path: string) => { if (path === '/dashboard' && location.pathname === '/dashboard-dimentorin') return false;