Problem/Motivation
Currently when the current URL matches one of the links in the menu it sets the "active" state on that link (on 1st, 2nd and 3rd menu item level). But if it turns out the URL is used in 2 different menus (as in the screenshot) both links will be set as active, resulting with several menus or sub-menus opened.
Steps to reproduce
- Navigate to
/admin/config/people/accounts - Both the "Account settings" under Configuration in the Administration menu and "Settings" in the User menu are set to Active.
Note: this happens right now because the User menu is not printing the real menu and has a manually added wrong link. Either way, this is a situation that will happen because we'll be opening the door to site builders to create and add menus. So we'll need to solve this anyway.

Proposed resolution
Decide how we should control that cases.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | user-menu-both-links-active.png | 42.23 KB | prashant.c |
| active-states.png | 135.85 KB | finnsky |
Issue fork navigation-3407158
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ckrinaGood point. Basically because we might end up having 2 custom menus with the same URLS. And we need to set a pattern.
I'd say the easier way should be the menu closer on the top should have more priority: it'd be faster to reach and to visually locate. An alternative would be to add weight to each menu, but imho that would add unnecessary complexity. What do other people think?
Note: I know this goes against removing the active state from Shortcuts that we worked on, but we'll work on changing a few things for that menu: we'll add the links directly as items in the menu in the new design.
Comment #3
ckrinaComment #4
ckrinaComment #6
prashant.cOne other scenario or bug I found related to multiple active links

such as when a URL strings matches will multiple anchor links in the menu multiple links getting active for example in user menu
hrefforView Profileis/userandhrefforEdit Profileis/user/1/edit. In this case both links highlighted.I have tried to fix it by making some tweaks, there might be other scenarios as well.
Thanks!
Comment #8
prashant.cChanging to NW as main issue regarding 2 menu links active having same URL still needs work as mentioned in #2
Comment #9
prashant.cIn my opinion, it's acceptable for multiple menu items to share the same link and display them as active. This is because, if we prioritize these links or don't highlight others as active, users and administrators may not be aware that there are multiple links with the same URL. Additionally, there could be intentional reasons for having multiple links with the same URL. As a result, this should not pose any harm, but further discussion or feedback is encouraged.
Thank you.
Comment #10
KeyboardCowboyWe're closing this issue as it works as designed. With the new Drawer designs this is no longer a UX issue. We can open a new issue if we find this to be a problem in future iterations.