fix: sidebar menu

This commit is contained in:
Sukma Gladys 2024-09-11 09:11:10 +07:00
parent 79c1e4a353
commit 13bacf6da0
2 changed files with 6 additions and 9 deletions

View File

@ -53,14 +53,11 @@ export default function AppNavbar(){
return () => window.removeEventListener('resize', handleResize);
}, []);
const [activeMenuId, setActiveMenuId] = useState<string>('');
const handleMenuItemClick = (id: string) => {
setActiveMenuId(id);
const handleMenuItemClick = () => {
if (window.innerWidth < 768) {
setSidebarOpen(false);
setSidebarOpen(false);
}
};
};
return (
<>

View File

@ -1,6 +1,6 @@
import { useState } from "react";
import * as TbIcons from "react-icons/tb";
import classNames from "./styles/navbarMenuItem.module.css";
// import classNames from "./styles/navbarMenuItem.module.css";
// import dashboardConfig from "../dashboard.config";
// import { usePathname } from "next/navigation";
// import areURLsSame from "@/utils/areUrlSame";
@ -45,9 +45,9 @@ export default function MenuItem({ menu, isActive, onClick }: Props) {
};
const handleClick = () => {
onClick(menu.link ?? ""); // Notify parent of the active menu item
onClick(menu.link ?? "");
if (!hasChildren) {
toggleOpenMenu(); // Collapse if no children
toggleOpenMenu();
}
};