@campxdev/react-blueprint 2.1.12 → 2.2.1
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/package.json
CHANGED
|
@@ -122,22 +122,71 @@ export const useSidebarNavigation = (
|
|
|
122
122
|
useEffect(() => {
|
|
123
123
|
const currentPathArray = window.location.pathname.split('/');
|
|
124
124
|
|
|
125
|
-
if (currentPathArray.length >
|
|
126
|
-
currentPathArray.splice(0,
|
|
127
|
-
|
|
125
|
+
if (currentPathArray.length > 3) {
|
|
126
|
+
currentPathArray.splice(0, 3); // Remove ['', 'aupulse', 'common-workspace']
|
|
127
|
+
// Remove the pop() - we need all remaining segments for navigation
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
// Build history stack while traversing to the active menu
|
|
131
|
+
const historyStack: MenuState[] = [];
|
|
132
|
+
let currentMenu = menu;
|
|
133
|
+
let currentPath = '';
|
|
134
|
+
let currentTitle: string | null = null;
|
|
135
|
+
|
|
136
|
+
// Traverse the path array to build history and find final menu state
|
|
137
|
+
for (let i = 0; i < currentPathArray.length; i++) {
|
|
138
|
+
const pathSegment = `/${currentPathArray[i]}`;
|
|
139
|
+
const item = currentMenu.find(
|
|
140
|
+
(item: SideMenuItemProps) => item.path === pathSegment,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
if (item && item.menu) {
|
|
144
|
+
if (i < currentPathArray.length - 1) {
|
|
145
|
+
// This is an intermediate level - add current level to history before moving deeper
|
|
146
|
+
historyStack.push({
|
|
147
|
+
title: currentTitle,
|
|
148
|
+
path: currentPath || null,
|
|
149
|
+
menu: currentMenu,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Move to next level
|
|
154
|
+
currentMenu = item.menu;
|
|
155
|
+
currentPath += item.path;
|
|
156
|
+
currentTitle = item.name;
|
|
157
|
+
} else {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Set the final menu state if we found nested menus
|
|
163
|
+
let finalMenuState: MenuState = currentMenuState;
|
|
164
|
+
if (currentPath) {
|
|
165
|
+
finalMenuState = {
|
|
166
|
+
title: currentTitle,
|
|
167
|
+
path: currentPath,
|
|
168
|
+
menu: currentMenu,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// If we have history, it means we're in a nested menu
|
|
173
|
+
if (historyStack.length > 0) {
|
|
174
|
+
setHistory(historyStack);
|
|
175
|
+
setCurrentMenuState(finalMenuState);
|
|
176
|
+
} else {
|
|
177
|
+
// Fallback to the original logic for non-nested menus
|
|
178
|
+
const activeMenu = getActiveMenu({
|
|
179
|
+
menu: currentMenuState.menu,
|
|
180
|
+
pathArray: currentPathArray,
|
|
181
|
+
previousMenuState: currentMenuState,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
setCurrentMenuState({
|
|
185
|
+
title: activeMenu?.title,
|
|
186
|
+
path: activeMenu.path,
|
|
187
|
+
menu: activeMenu?.menu,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
141
190
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
191
|
}, []);
|
|
143
192
|
|