ResponsiveMenus sometimes adds multiple click handlers to the toggle and accordion controls breaking them

Created on 23 May 2024, 6 months ago

Problem/Motivation

Sometimes when the page loads, at.responsivemenu.js will apply a click event handler to the responsive menu toggles multiple times. If that number is an even number, clicking the toggle will result in the first handler changing the state of the menu, then the second handler changing it back. I believe it has to do with how Drupal now handles Drupal.behaviors apply functionality with bigpipe causing our themes behaviors to be applied twice in some circumstances.

Steps to reproduce

  1. Enable newly created subtheme.
  2. Enable Responsive Menus extension
  3. Default style: Slide down
  4. Responsive style: Drop menu
  5. Ensure the menu has some items with children.
  6. Logged in, load a page with the menu displayed and ensure the browser is small enough to use the Slide down style.
  7. Click the hamburger menu button

These steps work for me, with the important part being that I'm logged in. Anonymous visiting the site the hamburger menu item only seems to get a single click handler attached, though I've had reports from users that logging out after having logged in does cause the issue to occur sometimes. (caching somehow?!!?!?)

Proposed resolution

Use drupal/once to ensure we only add the click handler once.

Remaining tasks

I am unsure how the minified js files are compiled, so my patch comments out at.responsiveMenus.min.js and uncomments the non-minified version. I'll make a merge request with my changes, but if someone could minify the resulting at.responsiveMenus.js we can undo that change in at_core.libraries.yml.

User interface changes

none

API changes

none

Data model changes

none

πŸ› Bug report
Status

Active

Version

7.0

Component

Extensions

Created by

πŸ‡ΊπŸ‡ΈUnited States redeight

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024