Problem/Motivation
New to 11.3 is a regression where Olivero's dropdown menus don't work if you're logged in, and Big Pipe is enabled (which it is by default).
This is likely a regression caused by changes to Big Pipe with HTMX. However the root cause is Olivero's. /core/themes/olivero/js/second-level-navigation.js does not use Drupal Behaviors 🙈
Steps to reproduce
- Install default Drupal
- Add a nested menu structure
- Be logged in, and try to access a nested menu item. It doesn't work
Proposed resolution
Lets use behaviors in /core/themes/olivero/js/second-level-navigation.js
Release notes snippet
Issue fork drupal-3568566
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3568566-oliveros-secondary-menus
changes, plain diff MR !14428
Comments
Comment #2
mherchelCrediting @mandclu who reported the issue at https://drupal.slack.com/archives/C0D5GJZ8B/p1768834175431069
Comment #4
mherchelComment #5
mherchelThe MR above moves the event listeners into a new Drupal behavior.
Comment #6
mherchelComment #7
mandclu commentedI tested this on a fresh install of Drupal 11.3. Where previously it would show just the context menu but not the dropdown for nested items in the main navigation on hover, with the patch applied the menu works as expected even when logged in as an admin.
Comment #8
godotislateI was curious about why HTMX would make a difference, if the issue was that Olivero did not use behaviors, so I did some investigation with these steps:
On
11.2.x,the hover behavior of the home link on the first cold page load does not work as expected. It does work subsequently on reloads. This does confirm it's Big Pipe related, but 11.2.x does not use HTMX for Big Pipe.I also tested against
11.1.x, and the hover behavior of the home link on the first cold page load does work as expected. If anything, either the issue was introduced between 11.1.x and 11.2.x (not going to do a git bisect now) or it was a race condition.Comment #9
catchBased on #8, pretty sure it was #3437499: Use placeholdering for more blocks - before that issue, the main menu would be rendered with the main content, after that issue, on cache misses, it's rendered via big pipe, on cache hits, as part of the main content again (due to another change that landed in 11.2).
Comment #11
lauriiiReviewed the patch and made the following improvements:
init(el)parameter toinit(navElement)to avoid variable shadowing with theelused inside theforEachcallbacksinit()functiononce()to prevent duplicate handlers when the behavior is attached to multiple elementsComment #12
godotislateTested updated MR locally with same steps per #8 and still works as expected.
Comment #17
lauriiiThank you for the review @godotislate! Committed 🚀
Comment #20
kentr commentedI think this caused a regression: #3584314: Mobile menu doesn't close by ESC key with search block + empty main menu