I have discovered a bug in the Cassiopeia theme, and I can't find a solution to it, and I don't even know what's causing it.
Searching, I found such a page, and it appears here, on several browsers: https://cassiopeia.joomla.com/help/menu-module
When in mobile view, and I open the hamburger menu ("Page Modules" - menu module settings in the "Advanced" tab under "Layout" - "Collapsible Dropdown" ), then open the submenus, any of them, then close the entire hamburger menu as is, then open it again... If you play this for a while, randomly, something will get stuck, and suddenly their collapsible submenus won't open. I'm watching the inspector, can't find the cause of the error.
Has anyone experienced anything similar?
Does anyone know what could cause this bug?
It's probably a javascript error, but I can't fix it, I don't understand OOP JS that well
The mobile menu works properly and does not get stuck.
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Information Required
|
Yes, I saw it afterwards, sorry!
I could repeat it, on localhost, with a fresh install, without any settings. Unfortunately, the error occurred there too. It must be a cassiopeia error, I just can't find where to write about it.
Labels |
Removed:
Information Required
|
Labels |
Added:
bug
|
The bug was also reproduced at joomla.stackexchange https://joomla.stackexchange.com/a/33969/87
@richard67 I found that the issue is in this file: build/media_source/templates/site/cassiopeia/js/mod_menu/menu-metismenu.es6.js
I also found out that the Problem occurs when the transitioning is delayed then sometimes the collapsing class and the inline 0px are not removed from the submenu
But I dont have enough Javascript skills to fix it. Since you wrote that block, maybe you know what to do to fix it? The issue only appears in Chrome.
@richard67 I found that the issue is in this file: build/media_source/templates/site/cassiopeia/js/mod_menu/menu-metismenu.es6.js I also found out that the Problem occurs when the transitioning is delayed then sometimes the collapsing class and the inline 0px are not removed from the submenu But I dont have enough Javascript skills to fix it. Since you wrote that block, maybe you know what to do to fix it? The issue only appears in Chrome.
@coolcat-creations I am no javascript expert either, and I don't remember having written that block.
Sorry I misinterpreted the information in the IDE, was it @dgrammatiko ?
Without testing anything I can only comment on the code and it seems that there's a racing condition on lines https://github.com/joomla/joomla-cms/blob/5.2-dev/build/media_source/templates/site/cassiopeia/js/mod_menu/menu-metismenu.es6.js#L18-L19
The mm.hide(event.detail.shownElement);
is an asynchronous fn and needs to finish any animations before calling synchronous the next line window.removeEventListener('click', mmClick);
. Probably there's another event when the hide has finished and if so the next line should execute there. If not before calling the mm.hide()
the animation should be tracked and fire the removeListener on the animation.finished. Either would work the first is way easier (if there's such an event)
Edit: There is a hidden
event which fires when the animation is finished (?) so this code should work:
document.querySelectorAll('ul.mod-menu_dropdown-metismenu').forEach((menu) => {
// eslint-disable-next-line no-new, no-undef
const mm = new MetisMenu(menu, {
triggerElement: 'button.mm-toggler',
}).on('shown.metisMenu', (event) => {
window.addEventListener('click', function mmClick(e) {
if (!event.target.contains(e.target)) {
mm.addEventListener('hidden.metisMenu', (ev) => {
window.removeEventListener('click', mmClick);
});
mm.hide(event.detail.shownElement);
}
});
});
});
BTW the blame doesn't mention me so not my code 🤷♂️
@dgrammatiko @richard67 sorry in my IDE I had this "Info" in my screen that's why I asked first Richard,
Yesterday I checked the file then with my phone and could not find blame, but it was mentioning you Dimitris in the history, no idea why.
:-)
Thank you for the code, I will test it and create a PR if its working
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-10-10 12:12:41 |
Closed_By | ⇒ | richard67 |
This is a privete demo site, not Jooma core.
Can you replicate the effect with an own freshly installed site with cassiopeia?