fix: auto-expand sidebar group containing current route on page load
This commit is contained in:
@@ -164,7 +164,15 @@ export const BackofficeSidebar: FC<SidebarProps> = ({
|
|||||||
}): ReactElement => {
|
}): ReactElement => {
|
||||||
const { signOut } = useSession();
|
const { signOut } = useSession();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const [openGroups, setOpenGroups] = useState<Record<string, boolean>>({});
|
const [openGroups, setOpenGroups] = useState<Record<string, boolean>>(() => {
|
||||||
|
const initial: Record<string, boolean> = {};
|
||||||
|
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) => {
|
const isActive = (path: string) => {
|
||||||
if (path === '/dashboard' && location.pathname === '/dashboard-dimentorin')
|
if (path === '/dashboard' && location.pathname === '/dashboard-dimentorin')
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user