admin-toolbar-wrapper: Uncaught TypeError: doc.querySelector(...) is null

Created on 30 December 2024, 2 months ago

Problem/Motivation

For anonymous users, the javascript file admin-toolbar-wrapper.js gets loaded for some reason that I could figure out. That then issues the following error on the browser console:

Uncaught TypeError: doc.querySelector(...) is null
    attach https://www.example.com/core/modules/navigation/js/admin-toolbar-wrapper.js?v=10.4.0:71
    attach https://www.example.com/core/modules/navigation/js/admin-toolbar-wrapper.js?v=10.4.0:158
    attachBehaviors https://www.example.com/core/misc/drupal.js?v=10.4.0:166
    attachBehaviors https://www.example.com/core/misc/drupal.js?v=10.4.0:162
    <anonymous> https://www.example.com/core/misc/drupal.init.js?v=10.4.0:32
    listener https://www.example.com/core/misc/drupal.init.js?v=10.4.0:20

This is due to the following code:

              doc.querySelector('.admin-toolbar').dispatchEvent(
                new CustomEvent(SIDEBAR_CONTENT_EVENT, {
                  detail: {
                    state: newState,
                  },
                }),
              );

Proposed resolution

Check for .admin-toolbar being present.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

navigation.module

Created by

πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

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