Commit 9549e06a authored by Julian Pustkuchen's avatar Julian Pustkuchen Committed by David Suissa
Browse files

Issue #3532249 by anybody, dydave: Fixed JS error 'Uncaught TypeError:...

Issue #3532249 by anybody, dydave: Fixed JS error 'Uncaught TypeError: toolbarElement.querySelector(...) is null' when selected HTML IDs are not found in the page.
parent 0412425d
Loading
Loading
Loading
Loading
Loading

.eslintignore

0 → 100644
+6 −0
Original line number Diff line number Diff line
#
# ESLint ignore file for the Admin Toolbar project.
#

# Exclude external hoverIntent jQuery Plugin library from eslint validation.
js/jquery.hoverIntent.js
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@
  z-index: 1;
  display: block;
  width: 200px;
  box-shadow: 2px 2px 3px hsla(0, 0%, 0%, 0.4);
  box-shadow: 2px 2px 3px hsl(0, 0%, 0%, 0.4);
}

.toolbar-tray-horizontal ul li.menu-item--expanded .menu-item > ul {
+31 −23
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
        const toolbarElement = document.getElementById(
          'toolbar-administration',
        );
        if (toolbarElement) {
          // Create a toggle link to show the toolbar from the HTML string
          // template and insert it after the toolbar element.
          toolbarElement.insertAdjacentHTML(
@@ -63,19 +64,26 @@
            'click',
            this.toggle,
          );

          // Create a toggle link to hide the toolbar from the HTML string
          // template and insert the toggle link as the last toolbar tab item.
        toolbarElement.querySelector('#toolbar-bar').insertAdjacentHTML(
          const toolbarBar = toolbarElement.querySelector('#toolbar-bar');
          if (toolbarBar) {
            toolbarBar.insertAdjacentHTML(
              // The toolbar tab item is inserted as the last item in the toolbar.
              'beforeend',
              Drupal.theme.adminToolbarToggleCollapse(),
            );
          }

          // Add a click event listener to the collapse button.
        toolbarElement
          .querySelector(
          const toolbarIconCollapse = toolbarElement.querySelector(
            '.toolbar-tab--collapse-trigger .toolbar-icon-collapse',
          )
          .addEventListener('click', this.toggle);
          );
          if (toolbarIconCollapse) {
            toolbarIconCollapse.addEventListener('click', this.toggle);
          }
        }
      });
    },
    // Toggle the display of the toolbar from visible to hidden and vice versa.
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ class AdminToolbarSettingsForm extends ConfigFormBase {
    $form['hoverintent_behavior']['timeout'] = [
      '#type' => 'select',
      '#title' => $this->t('hoverIntent timeout (ms)'),
      '#field_suffix' => 'milliseconds',
      '#field_suffix' => $this->t('milliseconds'),
      '#description' => $this->t('Sets the hoverIntent trigger timeout (steps of 250).<br>The higher the value, the longer the menu dropdown stays visible, after the mouse moves out (default: 500ms).'),
      '#options' => array_combine($timeout_range_values, $timeout_range_values),
      '#default_value' => $config->get('hoverintent_behavior')['timeout'],