Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Note that this doesn't happen in Drupal 9 🤷♂️
Steps to reproduce:
- Log in as an administrator
- Be on a narrow screen and try to open Olivero's mobile menu.
Result, the mobile menu will fail to open and a console error appears.
Uncaught TypeError: Cannot read properties of null (reading 'classList')
at toggleNav (js_XR61NWgw_L_Ks9JiXTThE4s2nGDGANLv7YKBVTVLpGo.js?scope=footer&delta=0&language=en&theme=olivero&include=contextual/drupal.contextual-links%2Csystem/base%2Colivero/global-styling%2Ccore/drupal.active-link%2Colivero/powered-by-block%2Colivero/feed%2Cshortcut/drupal.shortcut%2Colivero/navigation-secondary%2Colivero/search-wide%2Colivero/navigation-primary%2Colivero/search-narrow%2Ccore/drupal.debounce%2Ccore/drupal.announce%2Ctoolbar/toolbar%2Cuser/drupal.user.icons%2Ccore/internal.shepherd%2Ctour/tour-styling%2Ctour/tour%2Ctoolbar/toolbar.escapeAdmin%2Ccore/drupal.tabbingmanager%2Ccontextual/drupal.contextual-toolbar%2Csettings_tray/drupal.settings_tray%2Cbig_pipe/big_pipe:3922:16)
Cause
This is caused by the navigation's init function improperly assuming that context == document
. Within D9 that is the case, but in D10, the first behavior to run has a context == body
, which breaks this script when it runs a context.querySelector('body')
.
Comment | File | Size | Author |
---|---|---|---|
#6 | 3319325-5-test-only-FAIL.patch | 827 bytes | mherchel |
#6 | 3319325-5.patch | 1.35 KB | mherchel |
|
Comments
Comment #2
mherchelNote I have a working fix on my local and will post a patch today or tomorrow. I want to understand the issue and why it's broken in D10 only.
Comment #3
mherchelComment #4
mherchelEditing issue summary to add cause
Comment #5
mherchelHere's a patch that fixes the issue. I'm unable to get Nightwatch running locally to write a proper test so far :(
Comment #6
mherchelGot Nightwatch working. Test attached.
Comment #7
mherchelComment #8
nod_This is following #3196973: Use Mutation observer for BigPipe replacements. Fix is correct.
Comment #9
alexpottDiscussed this issue with @nod_ because it points to breaking changes in #3196973: Use Mutation observer for BigPipe replacements. We agreed that that issue needs a follow-up but we should continue here because this is making assumptions about context it should not - see #3160052: Initial argument passed to Drupal behaviors is incorrect
Comment #10
andypostComment #14
nod_Comment #15
lauriiiCommitted 0b03053 and pushed to 10.1.x. Also cherry-picked to 10.0.x Thanks!
I commented to #3160052: Initial argument passed to Drupal behaviors is incorrect. I'm still wondering if we should do something about the BC break caused by the Big Pipe change to avoid disruption to custom code that has made this same assumption. I opened follow-up where we can discuss that: #3320059: Follow-up to #3196973: Context change.
Comment #16
lauriiiThank you @nod_! Closed #3320059: Follow-up to #3196973: Context change in favor of #3320055: Use document in bigpipe first attachBehaviors call.
Comment #17
lauriiiUpdating credits since they got lost on the cross-post.