Olivero: Toggle Nav does not always open and produces error Uncaught TypeError: Cannot read properties of null (reading 'classList') in console

Created on 23 March 2023, over 1 year ago
Updated 28 April 2023, about 1 year ago

Problem/Motivation

Our Drupal 9 site using Olivero's toggle navigation is not consistently opening the nav menu when the "menu" button is selected. The menu button will "animate" after a mouse click but will not actually open.

The following error is captured in the Console:

navigation.js?v=9.5.5:15 Uncaught TypeError: Cannot read properties of null (reading 'classList')
at toggleNav (navigation.js?v=9.5.5:15:18)
at HTMLButtonElement. (navigation.js?v=9.5.5:28:7)

Steps to reproduce

1. Load site
2. Navigate to a content node
3. Attempt to open the toggle nav
4. If toggle nav works, perform a cache reload (drush cr)
5. Attempt to open the toggle nav

These steps and the consistency of the bug is not 100% but it is happening quite often for us on our site.

Proposed resolution

Nav always opens without issue

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

9.5

Component
Olivero 

Last updated about 7 hours ago

Created by

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

Comments & Activities

  • Issue created by @sbrenner02
  • 🇺🇸United States mherchel Gainesville, FL, US

    The Olivero project is moved into core. This might be a duplicate of #3319325: Olivero: Mobile menu does not work when authenticated and BigPipe enabled(D10 only) , but pretty sure that was D10 only.

    If you point me to your site, I can take a look

  • @mherchel this is happening on desktop and not mobile (have not looked for it on mobile yet). Also our site is currently not public nor will it be public accessible when its live

  • It does seem to be the same issue as linked above however that patch is for 10 and does not work for 9. I've created a 9.5.x version of the same patch. I've done a lot of local testing and it does seem to resolve the issue, so thanks for the help!

  • Updated the patch to also include the es6 navigation file

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States andy-blum Ohio, USA

    @sbrenner02 thanks for the issue and the patches! A couple of housekeeping points:

    1. Please name your patches relative to the comment in which they are posted, not sequentially numbered. For example 3350013-2 should be 3350013-6. This helps avoid confusion in longer chains so "patch #6" and "the patch in comment #6" don't mean two different things
    2. After posting a patch, please remember to update the issue to "needs review" so the maintainers (Mike and I in this case) and others know it's ready for people to look at.
  • 🇮🇳India _utsavsharma

    Tried to fix CCF for #6.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    So I'm on 10.1.x and the olivero nav opens without issue.

    Cleared cache and confirmed it still opens.

    Could you provide a small video of the issue?

    Also seems like the kind of bug that would need a test case.

  • 🇺🇸United States andy-blum Ohio, USA

    @smustgrave this issue is 9.5.x

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sahil.goyal

    Hi! Thank you for providing more information and updating the recordings to help explain the issue. From what you've described, it sounds like the problem occurs when we toggle the navigation but what i found is when the page's body element changes size or when the user scrolls out of the body element's scope, looks like navigation bar does not able to target body element correctly.
    I'm updating recording of the after and before patch os it makes the issue to understand what i'm referring to.

    i'm confirming that #8 is the correct patch to address the issue. The patch targets the body element correctly in the navigation, which should ensure that the toggle button works correctly regardless of any changes to the body element's size or scrolling.

    Let me know if you have any other questions or concerns!
    RTBC +1

  • Status changed to RTBC about 1 year ago
  • 🇺🇸United States mherchel Gainesville, FL, US

    I'm fine with committing this. We made the same change in Drupal 10.0.x, but since we didn't see the issue in 9.5.x, it never got backported.

    We now have evidence that the problem is occurring so let's fix this. This is a very small and easy to understand patch.

    • nod_ committed 8d853d14 on 9.5.x
      Issue #3350013 by sbrenner02, _utsavsharma, _KASH_, sahil.goyal: Olivero...
  • 🇫🇷France nod_ Lille

    Committed 8d853d1 and pushed to 9.5.x. Thanks!

  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024