Skip to content

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

@justinherrin

Description

@justinherrin

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions