Note that this doesn't happen in Drupal 9 🤷‍♂️

Steps to reproduce:

  1. Log in as an administrator
  2. 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').

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mherchel created an issue. See original summary.

mherchel’s picture

Assigned: Unassigned » mherchel

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

mherchel’s picture

Issue summary: View changes
mherchel’s picture

Issue summary: View changes

Editing issue summary to add cause

mherchel’s picture

Status: Active » Needs review
FileSize
558 bytes

Here's a patch that fixes the issue. I'm unable to get Nightwatch running locally to write a proper test so far :(

mherchel’s picture

Got Nightwatch working. Test attached.

mherchel’s picture

Title: Olivero: Mobile menu does not work when toolbar present (D10 only) » Olivero: Mobile menu does not work when authenticated and BigPipe enabled(D10 only)
nod_’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Discussed 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

andypost’s picture

  • lauriii committed 0b03053 on 10.1.x
    Issue #3319325 by mherchel, nod_, alexpott: Olivero: Mobile menu does...

  • lauriii committed 0bc2ddc on 10.0.x
    Issue #3319325 by mherchel, nod_, alexpott: Olivero: Mobile menu does...

nod_ credited lauriii.

nod_’s picture

lauriii’s picture

Version: 10.1.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Fixed

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

lauriii’s picture

lauriii’s picture

Updating credits since they got lost on the cross-post.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.