Fix menu-open class handling on treeview #5888
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Prevent incorrect
menu-open
behavior on sidebar items without childrenCurrently, the
menu-open
class is added or removed on all.nav-item
elements in the sidebar, regardless of whether they contain a submenu. This leads to an unintended UX issue: clicking multiple links withhref="#"
causes multiple items to appear as active/open, even if they don’t have a child menu. This creates the misleading impression that several unrelated items are "open" at once.For example, in the screenshot below (taken from the AdminLTE demo), clicking on items like
Important
,Warning
, etc., triggers this issue:What's changed
This PR updates the behavior to ensure that the
menu-open
class is only toggled on.nav-item
elements that contain a child.nav-treeview
menu. The proposed fix avoids creating Treeview instances on elements that does not have a submenu (like a link element).