Commit dc7dc132 by Arjun Jhukal

updated the mobile menu close on redirection

parent ff4a7580
...@@ -11,11 +11,18 @@ import Breadcrumb from '../molecules/Breadcrumb'; ...@@ -11,11 +11,18 @@ import Breadcrumb from '../molecules/Breadcrumb';
export default function DashboardLayout({ children }: { children: React.ReactNode }) { export default function DashboardLayout({ children }: { children: React.ReactNode }) {
const [open, setOpen] = React.useState(true); const [open, setOpen] = React.useState(true);
const [openMobile, setOpenMobile] = React.useState(false); const [openMobile, setOpenMobile] = React.useState(false);
const pathname = usePathname();
const handleDrawerOpen = () => { const handleDrawerOpen = () => {
setOpen((prev) => !prev); setOpen((prev) => !prev);
}; };
React.useEffect(() => {
// Close menu when route changes
if (openMobile) {
setOpenMobile(false);
}
}, [pathname]);
const handleMobileMenuToggle = () => { const handleMobileMenuToggle = () => {
setOpenMobile((prev) => !prev); setOpenMobile((prev) => !prev);
} }
...@@ -31,7 +38,6 @@ export default function DashboardLayout({ children }: { children: React.ReactNod ...@@ -31,7 +38,6 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
...theme.mixins.toolbar, ...theme.mixins.toolbar,
})); }));
const pathname = usePathname();
return ( return (
<Box sx={{ display: 'flex' }}> <Box sx={{ display: 'flex' }}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment