ui-soxo-bootstrap-core 2.4.25-dev.27 → 2.4.25-dev.29
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.
|
@@ -158,7 +158,6 @@ export default function SideMenu({ loading, modules = [], callback, appSettings,
|
|
|
158
158
|
|
|
159
159
|
// callback();
|
|
160
160
|
// };
|
|
161
|
-
|
|
162
161
|
|
|
163
162
|
const onMenuClick = (menu, index) => {
|
|
164
163
|
const key = menu.path || `menu-${menu.id || index}`;
|
|
@@ -176,19 +175,52 @@ export default function SideMenu({ loading, modules = [], callback, appSettings,
|
|
|
176
175
|
setMenu(menu);
|
|
177
176
|
if (callback) callback();
|
|
178
177
|
};
|
|
179
|
-
|
|
180
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Controls submenu open/close behavior.
|
|
181
|
+
*
|
|
182
|
+
* - Detects the most recently opened menu key.
|
|
183
|
+
* - When opening a submenu, keeps only its full parent path expanded
|
|
184
|
+
* (accordion behavior).
|
|
185
|
+
* - When closing a submenu, updates state without recalculating paths.
|
|
186
|
+
*
|
|
187
|
+
* @param {string[]} keys - Currently open menu keys from the Menu component.
|
|
188
|
+
*
|
|
189
|
+
* Assumptions:
|
|
190
|
+
* - Menu keys are stable and unique.
|
|
191
|
+
* - Only one menu branch should be open at a time.
|
|
192
|
+
*/
|
|
181
193
|
const onOpenChange = (keys) => {
|
|
182
194
|
const latestOpenKey = keys.find((k) => !openKeys.includes(k));
|
|
183
195
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
setOpenKeys([latestOpenKey]);
|
|
196
|
+
if (!latestOpenKey) {
|
|
197
|
+
setOpenKeys(keys);
|
|
187
198
|
return;
|
|
188
199
|
}
|
|
189
200
|
|
|
190
|
-
|
|
191
|
-
|
|
201
|
+
const findPath = (items) => {
|
|
202
|
+
const sortedItems = Menus.screenMenus(items, 'order');
|
|
203
|
+
for (const item of sortedItems) {
|
|
204
|
+
const key = String(item.id || item.path || item.caption);
|
|
205
|
+
if (key === latestOpenKey) {
|
|
206
|
+
return [key];
|
|
207
|
+
}
|
|
208
|
+
if (item.sub_menus) {
|
|
209
|
+
const childPath = findPath(item.sub_menus);
|
|
210
|
+
if (childPath) {
|
|
211
|
+
return [key, ...childPath];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const path = findPath(modules);
|
|
219
|
+
if (path) {
|
|
220
|
+
setOpenKeys(path);
|
|
221
|
+
} else {
|
|
222
|
+
setOpenKeys(keys);
|
|
223
|
+
}
|
|
192
224
|
};
|
|
193
225
|
|
|
194
226
|
/**
|
|
@@ -214,7 +246,7 @@ export default function SideMenu({ loading, modules = [], callback, appSettings,
|
|
|
214
246
|
// document.documentElement.style.setProperty('--custom-text-color', state.theme.colors.colorText);
|
|
215
247
|
}, [state.theme]);
|
|
216
248
|
|
|
217
|
-
const rootSubmenuKeys = Menus.screenMenus(modules, 'order').map((m) => m.path || m.caption);
|
|
249
|
+
const rootSubmenuKeys = Menus.screenMenus(modules, 'order').map((m) => m.id || m.path || m.caption);
|
|
218
250
|
|
|
219
251
|
return (
|
|
220
252
|
<div className="sidemenu">
|
|
@@ -354,7 +386,7 @@ export default function SideMenu({ loading, modules = [], callback, appSettings,
|
|
|
354
386
|
style={{ color: state.theme.colors.leftSectionColor }}
|
|
355
387
|
// key={`first-level-${randomIndex}-${menu.caption}`}
|
|
356
388
|
|
|
357
|
-
key={menu.path || menu.caption}
|
|
389
|
+
key={menu.id || menu.path || menu.caption}
|
|
358
390
|
title={
|
|
359
391
|
<>
|
|
360
392
|
<CollapsedIconMenu
|
|
@@ -377,7 +409,7 @@ export default function SideMenu({ loading, modules = [], callback, appSettings,
|
|
|
377
409
|
className="popup"
|
|
378
410
|
// key={`second-level-${randomIndex}-${submenu.id}`}
|
|
379
411
|
|
|
380
|
-
key={submenu.path || submenu.caption}
|
|
412
|
+
key={submenu.id || submenu.path || submenu.caption}
|
|
381
413
|
title={
|
|
382
414
|
<span>
|
|
383
415
|
<CollapsedIconMenu
|