Feature Request Description
When a ui5-side-navigation-group (or item with sub-items) is expanded or collapsed, no event is fired. The _toggle() method in SideNavigationGroup simply sets this.expanded = !this.expanded without calling fireDecoratorEvent().
The only event ui5-side-navigation currently fires is selection-change (when an item is selected). There is no way to be notified about expand/collapse state changes.
We need to persist the expanded/collapsed state of navigation groups (e.g. to localStorage) so that the user's preferred navigation layout survives page reloads or route changes. Without an event, the only workaround is a MutationObserver watching the expanded attribute on all child elements — which works but is fragile and non-idiomatic for a web component:
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes') {
const target = mutation.target;
if (target.hasAttribute('expanded')) {
// persist state
}
}
});
});
observer.observe(sideNavigation, {
attributes: true,
subtree: true,
attributeFilter: ['expanded'],
});
This workaround relies on the expanded attribute being reflected to the DOM as an HTML attribute on the child elements. If UI5 internally refactors to use CSS classes, shadow DOM state, or stops reflecting the attribute, the observer silently breaks without warning.
Additionally, ui5-tree already fires an item-toggle event with { item } when a tree node is expanded/collapsed. The side navigation should behave consistently — users expect the same interaction patterns across UI5 components.
Proposed Solution
An event on ui5-side-navigation itself (similar to how selection-change bubbles up from items):
Event: expand-change
detail: { item: HTMLElement, expanded: boolean, programmatic: boolean }
This would fire whenever a group or item toggles its expanded state — whether triggered by click, keyboard (arrow keys, +/−), or programmatically.
The event should fire both on user interaction and when expanded is set programmatically. Our use case requires tracking all expand/collapse state changes regardless of trigger — for example, when navigation groups are expanded programmatically during route changes, the persisted state in localStorage must stay in sync. A flag like programmatic: boolean in the event detail could help consumers distinguish the source if needed, but firing in both cases is essential.
Proposed Alternatives
No response
Organization
luigi-project
Additional Context
No response
Priority
Medium
Privacy Policy
Feature Request Description
When a
ui5-side-navigation-group(or item with sub-items) is expanded or collapsed, no event is fired. The_toggle()method inSideNavigationGroupsimply setsthis.expanded = !this.expandedwithout callingfireDecoratorEvent().The only event
ui5-side-navigationcurrently fires isselection-change(when an item is selected). There is no way to be notified about expand/collapse state changes.We need to persist the expanded/collapsed state of navigation groups (e.g. to localStorage) so that the user's preferred navigation layout survives page reloads or route changes. Without an event, the only workaround is a MutationObserver watching the
expandedattribute on all child elements — which works but is fragile and non-idiomatic for a web component:This workaround relies on the
expandedattribute being reflected to the DOM as an HTML attribute on the child elements. If UI5 internally refactors to use CSS classes, shadow DOM state, or stops reflecting the attribute, the observer silently breaks without warning.Additionally,
ui5-treealready fires anitem-toggleevent with{ item }when a tree node is expanded/collapsed. The side navigation should behave consistently — users expect the same interaction patterns across UI5 components.Proposed Solution
An event on
ui5-side-navigationitself (similar to howselection-changebubbles up from items):This would fire whenever a group or item toggles its expanded state — whether triggered by click, keyboard (arrow keys, +/−), or programmatically.
The event should fire both on user interaction and when
expandedis set programmatically. Our use case requires tracking all expand/collapse state changes regardless of trigger — for example, when navigation groups are expanded programmatically during route changes, the persisted state in localStorage must stay in sync. A flag likeprogrammatic: booleanin the event detail could help consumers distinguish the source if needed, but firing in both cases is essential.Proposed Alternatives
No response
Organization
luigi-project
Additional Context
No response
Priority
Medium
Privacy Policy