No Code Attached Yet bug
avatar xeno024
xeno024
26 Sep 2024

What needs to be fixed

Why this should be fixed

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?

How would you fix it

It's probably a javascript error, but I can't fix it, I don't understand OOP JS that well

Side Effects expected

The mobile menu works properly and does not get stuck.

avatar xeno024 xeno024 - open - 26 Sep 2024
avatar joomla-cms-bot joomla-cms-bot - change - 26 Sep 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 26 Sep 2024
avatar chmst
chmst - comment - 29 Sep 2024

This is a privete demo site, not Jooma core.

Can you replicate the effect with an own freshly installed site with cassiopeia?

avatar chmst chmst - change - 29 Sep 2024
Labels Added: Information Required
avatar chmst chmst - labeled - 29 Sep 2024
avatar xeno024
xeno024 - comment - 30 Sep 2024

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.

avatar Quy Quy - change - 30 Sep 2024
Labels Removed: Information Required
avatar Quy Quy - unlabeled - 30 Sep 2024
avatar Fedik Fedik - change - 3 Oct 2024
Labels Added: bug
avatar Fedik Fedik - labeled - 3 Oct 2024
avatar Fedik
Fedik - comment - 3 Oct 2024

The bug was also reproduced at joomla.stackexchange https://joomla.stackexchange.com/a/33969/87

avatar coolcat-creations
coolcat-creations - comment - 9 Oct 2024

@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.

avatar richard67
richard67 - comment - 9 Oct 2024

@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.

avatar coolcat-creations
coolcat-creations - comment - 9 Oct 2024

Sorry I misinterpreted the information in the IDE, was it @dgrammatiko ?

avatar dgrammatiko
dgrammatiko - comment - 9 Oct 2024

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 🤷‍♂️

avatar coolcat-creations
coolcat-creations - comment - 10 Oct 2024

@dgrammatiko @richard67 sorry in my IDE I had this "Info" in my screen that's why I asked first Richard,

Image

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.

Image

:-)

Thank you for the code, I will test it and create a PR if its working

avatar richard67 richard67 - change - 10 Oct 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-10-10 12:12:41
Closed_By richard67
avatar richard67 richard67 - close - 10 Oct 2024
avatar richard67
richard67 - comment - 10 Oct 2024

Closing as having a pull request. Please test #44221 . Thanks in advance.

Add a Comment

Login with GitHub to post a comment