Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple links in admin main menu have active class applied #44785

Open
justinherrin opened this issue Jan 27, 2025 · 1 comment
Open

Multiple links in admin main menu have active class applied #44785

justinherrin opened this issue Jan 27, 2025 · 1 comment

Comments

@justinherrin
Copy link
Contributor

Hello all.

I built myself a custom component (com_medialibrary) and have it installed and running on Joomla 5. One odd thing I noticed is that multiple menu items in the main sidebar menu get highlighted as "active" despite me only viewing the Items view of my custom Media Library component.

See some screenshots below to help show what I am trying to explain...

Image

Unsure why both menu items are marked as "active".

Image

Now here only the single menu item is properly marked as "active".

Expected result

After navigating to the custom Media Library component Items view menu item, only com_medialibrary Items view menu item (/administrator/index.php?option=com_medialibrary) gets the mm-active class applied to it.

Actual result

After navigating to the custom Media Library component Items view menu item, both com_media default view menu item (administrator/index.php?option=com_media&path=local-images:/) and com_medialibrary Items view menu item (/administrator/index.php?option=com_medialibrary) get the mm-active class applied to both of them.

System information (as much as possible)

  • Joomla 5.2.3
  • Default Atum template and default navigation menu

Additional comments

I believe the "issue" to be related to the foreach if condition that begins on/around line 56 of media/mod_menu/js/admin-menu.js but I am not sure how exactly the admin menu works...

if (!link.href.match(/index\.php$/) && currentUrl.indexOf(link.href) === 0 || link.href.match(/index\.php$/) && currentUrl.match(/index\.php$/)) {

As if the Javascript code is incorrectly matching the URL strings.

This behavior only happens when I navigate to Components > Media Library > Items view (/administrator/index.php?option=com_medialibrary)

If I navigate to Content > Media (administrator/index.php?option=com_media&path=local-images:/) then only the Content > Media menu item gets the mm-active class applied, not the menu item in my custom component.

Any thoughts?

@chmst
Copy link
Contributor

chmst commented Jan 28, 2025

Similar effect here #35228 (comment) and #43907 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants