admin-menu.js
determines if a menu item should be marked as the active menu item and therefore also if its a child menu item if the menu should be expanded.
This problem was not faced in J3 and before as we had a drop down menu that was always collapsed and never even highlighted
In the front end we also don't face this problem because every link has an itemid and we match on that (how I wish we had called it menuid 17 years ago )
We therefore have to fix this either by adding the id in the admin (I'm guessing thats a no-no) or by changing the JS
The problem is with this piece of code
joomla-cms/build/media_source/mod_menu/js/admin-menu.es6.js
Lines 68 to 79 in a94bdc4
It is trying to match the url with a menu item and if it finds a match then the menu item is marked as active. This is done on every page load. The problem is that not every potential url has an exact match on the menu and when there is no match then nothing is marked as active and the menu collapses
index.php?option=com_media
but the url in the address bar is index.php?option=com_media&path=local-0:/
index.php?option=com_content&filter[category_id]=2&filter[published]=1&filter[level]=1
but the menu only has a menu item of /index.php?option=com_content&view=articles
Instead of looking for an exact match on every page load to find the active menu item it should look be looking for the nearest match,
Strip the url down before trying to find something it matches
index.php?option=com_media&path=local-0:/
==> no match
index.php?option=com_media
==> exact match
if no matches then build up until it matches
index.php?option=com_content&filter[category_id]=2&filter[published]=1&filter[level]=1
==> no match
index.php?option=com_content&filter[category_id]=2&filter[published]=1
==> no match
index.php?option=com_content&filter[category_id]=2
==>no match
index.php?option=com_content
==> no match
Menu item with closest match
Articles index.php?option=com_content&view=articles
if still no matches then use the referrer url for the menu not the active url
index.php?option=com_languages&view=installed
==> no match
index.php?option=com_languages
==> no match
No closest match use referrer System index.php?option=com_cpanel&view=cpanel&dashboard=system
Yes I know there are several other issues listing which urls dont work but this one has the reason so hopefully it will be easier for someone to see and fix
#33590 #32273 and probably more
Labels |
Added:
?
|
Not that rare - there is &extension and there is &context
index.php?option=com_categories&view=categories&extension=com_content
index.php?option=com_categories&view=categories&extension=com_contacts
index.php?option=com_categories&view=categories&extension=com_newsfeeds
index.php?option=com_fields&view=fields&context=com_content.article
index.php?option=com_fields&view=fields&context=com_content.categories
index.php?option=com_fields&view=fields&context=com_contacts.contact
index.php?option=com_fields&view=fields&context=com_contacts.categories
good point. but other than option, view, context and extension ... ?
Labels |
Added:
No Code Attached Yet
bug
Removed: ? |
Yup. This.
But also needs to be powerful for 3pd matches to.
Might be enough to only match on the component and the view in the url, it would be rare to have two menu items with the same component and view in the url params.