@cullsin/lnc-menu 3.0.21 → 3.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/SideMenu.js +11 -8
- package/package.json +1 -1
package/dist/src/SideMenu.js
CHANGED
|
@@ -52,26 +52,29 @@ function SideMenu({ useDrawer, SampleMgmtIcon, location }) {
|
|
|
52
52
|
path: "/carrier-duo-trio/",
|
|
53
53
|
},
|
|
54
54
|
], [SampleMgmtIcon]);
|
|
55
|
-
//
|
|
55
|
+
// 🔁 Sync selection with current path
|
|
56
56
|
React.useEffect(() => {
|
|
57
57
|
const currentPath = location.pathname;
|
|
58
58
|
for (const mainItem of menuItems) {
|
|
59
59
|
if (mainItem.subMenu) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
for (const sub of mainItem.subMenu) {
|
|
61
|
+
if (currentPath.startsWith(sub.path)) {
|
|
62
|
+
setSelectedMainMenu(mainItem.text);
|
|
63
|
+
setSelectedSubMenuPath(sub.path);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
else if (mainItem.path
|
|
68
|
+
else if (mainItem.path && currentPath.startsWith(mainItem.path)) {
|
|
68
69
|
setSelectedMainMenu(mainItem.text);
|
|
69
70
|
setSelectedSubMenuPath(null);
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
setSelectedMainMenu(null);
|
|
75
|
+
setSelectedSubMenuPath(null);
|
|
73
76
|
handleMenuClose();
|
|
74
|
-
}, [location.pathname]);
|
|
77
|
+
}, [location.pathname, menuItems]);
|
|
75
78
|
const handleMenuOpen = (event, index) => {
|
|
76
79
|
setAnchorEl(event.currentTarget);
|
|
77
80
|
setOpenMenuIndex(index);
|