No Code Attached Yet
avatar justinherrin
justinherrin
27 Jan 2025

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?

avatar justinherrin justinherrin - open - 27 Jan 2025
avatar joomla-cms-bot joomla-cms-bot - change - 27 Jan 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Jan 2025
avatar chmst
chmst - comment - 28 Jan 2025

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

Add a Comment

Login with GitHub to post a comment