@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.
@@ -52,26 +52,29 @@ function SideMenu({ useDrawer, SampleMgmtIcon, location }) {
52
52
  path: "/carrier-duo-trio/",
53
53
  },
54
54
  ], [SampleMgmtIcon]);
55
- // Initialize selected menu based on current path
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 match = mainItem.subMenu.find((sub) => sub.path === currentPath);
61
- if (match) {
62
- setSelectedMainMenu(mainItem.text);
63
- setSelectedSubMenuPath(match.path);
64
- return;
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 === currentPath) {
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cullsin/lnc-menu",
3
- "version": "3.0.21",
3
+ "version": "3.0.22",
4
4
  "description": "Reusable SideMenu component for MedGenome LNC platform using MUI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",