ui-soxo-bootstrap-core 2.4.25-dev.28 → 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
- // If opening a ROOT menu → close other roots
185
- if (rootSubmenuKeys.includes(latestOpenKey)) {
186
- setOpenKeys([latestOpenKey]);
196
+ if (!latestOpenKey) {
197
+ setOpenKeys(keys);
187
198
  return;
188
199
  }
189
200
 
190
- // Otherwise (2nd / 3rd level) keep ALL parents open
191
- setOpenKeys(keys);
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
  /**
@@ -3,7 +3,7 @@ import themes from './themes.json';
3
3
  export const THEME_GROUPS = {
4
4
  nura: ['nura', 'default'],
5
5
  purple: ['purple'],
6
- default: ['default'],
6
+ default: ['nura'],
7
7
  };
8
8
 
9
9
  const currentEnvTheme = process.env.REACT_APP_THEME?.toLowerCase() || 'default';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui-soxo-bootstrap-core",
3
- "version": "2.4.25-dev.28",
3
+ "version": "2.4.25-dev.29",
4
4
  "description": "All the Core Components for you to start",
5
5
  "keywords": [
6
6
  "all in one"