Verified Commit d0e11e1d authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3504722 by plopesc, finnsky, smustgrave, catch, m4olivei: Navigation...

Issue #3504722 by plopesc, finnsky, smustgrave, catch, m4olivei: Navigation Expand/Collapse logic is not working properly in conjunction with Big Pipe
parent 7735d0ed
Loading
Loading
Loading
Loading
Loading
+66 −80
Original line number Diff line number Diff line
@@ -28,19 +28,9 @@
     */
    const SIDEBAR_CONTENT_EVENT = 'toggle-admin-toolbar-content';

    Drupal.behaviors.navigationProcessHtmlListener = {
      /**
       * Attaches the behavior to the context element.
       *
       * @param {HTMLElement} context The context element to attach the behavior to.
       */
      attach: (context) => {
        if (context === document) {
    if (
            once(
              'admin-toolbar-document-triggers-listener',
              document.documentElement,
            ).length
      once('admin-toolbar-document-triggers-listener', document.documentElement)
        .length
    ) {
      const doc = document.documentElement;

@@ -48,7 +38,7 @@
      // with animations and avoid layout shift.
      setTimeout(() => {
        doc.setAttribute('data-admin-toolbar-transitions', true);
            }, 200);
      }, 100);

      doc.addEventListener(HTML_TRIGGER_EVENT, (e) => {
        // Prevents multiple triggering while transitioning.
@@ -103,17 +93,13 @@
        const displaceElement = doc
          .querySelector('.admin-toolbar')
          ?.querySelector('.admin-toolbar__displace-placeholder');
              const edge =
                document.documentElement.dir === 'rtl' ? 'right' : 'left';
        const edge = document.documentElement.dir === 'rtl' ? 'right' : 'left';
        displaceElement?.setAttribute(`data-offset-${edge}`, '');
        Drupal.displace(true);
      };

      initDisplace();
    }
        }
      },
    };

    // Any triggers on page. Inside or outside sidebar.
    // For now button in sidebar + mobile header and background.
@@ -146,7 +132,7 @@
          localStorage.setItem('Drupal.navigation.sidebarExpanded', toState);
        };

        if (context === document) {
        if (triggers.length) {
          let firstState =
            localStorage.getItem('Drupal.navigation.sidebarExpanded') !==
            'false';
+4 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ const selectors = {
    expanded: '[data-admin-toolbar="expanded"]',
    collapsed: '[data-admin-toolbar="collapsed"]',
  },
  clearCacheButton: 'input[data-drupal-selector="edit-clear"]',
};

module.exports = {
@@ -15,6 +16,7 @@ module.exports = {
    browser
      .drupalInstall()
      .drupalInstallModule('navigation', true)
      .drupalInstallModule('big_pipe')
      .setWindowSize(1220, 800);
  },
  after(browser) {
@@ -24,7 +26,8 @@ module.exports = {
  'Expand/Collapse': (browser) => {
    browser.drupalLoginAsAdmin(() => {
      browser
        .drupalRelativeURL('/')
        .drupalRelativeURL('/admin/config/development/performance')
        .click(selectors.clearCacheButton)
        .waitForElementPresent(
          '[data-once="admin-toolbar-document-triggers-listener"]',
        )