Verified Commit a5cd2d7a authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3377900 by omkar.podey, lauriii, Gauravvvv, Utkarsh_33: Scrolling...

Issue #3377900 by omkar.podey, lauriii, Gauravvvv, Utkarsh_33: Scrolling remains disabled after closing nested modal dialogs
parent 3a661cf7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@
    function closeDialog(value) {
      $(window).trigger('dialog:beforeclose', [dialog, $element]);
      // Unlocks the body when the dialog closes.
      bodyScrollLock.unlock($element.get(0));
      bodyScrollLock.clearBodyLocks();

      $element.dialog('close');
      dialog.returnValue = value;
+0 −17
Original line number Diff line number Diff line
@@ -88,21 +88,4 @@
      bodyScrollLock.lock($scroll.get(0));
    }
  });

  /**
   * Binds a listener on dialog close to handle Views modal scroll.
   *
   * @param {jQuery.Event} e
   *   The event triggered.
   * @param {Drupal.dialog~dialogDefinition} dialog
   *   The dialog instance.
   * @param {jQuery} $element
   *   The jQuery collection of the dialog element.
   */
  $(window).on('dialog:beforeclose', (e, dialog, $element) => {
    const $scroll = $element.find('.scroll');
    if ($scroll.length) {
      bodyScrollLock.unlock($scroll.get(0));
    }
  });
})(jQuery, Drupal, drupalSettings, bodyScrollLock);
+22 −0
Original line number Diff line number Diff line
@@ -59,4 +59,26 @@ public function testAjaxRebuild() {
    $assert_session->pageTextContains('This is text added to the display edit form');
  }

  /**
   * Tests body scroll.
   */
  public function testBodyScroll() {
    $this->drupalGet('admin/structure/views/view/user_admin_people');
    $page = $this->getSession()->getPage();
    foreach (['name[views.nothing]', 'name[views.dropbutton]'] as $field) {
      $page->find('css', '#views-add-field')->click();
      $this->assertSession()->assertWaitOnAjaxRequest();
      $page->checkField($field);
      $this->assertSession()->assertWaitOnAjaxRequest();
      $page->find('css', '.ui-dialog-buttonset')->pressButton('Add and configure fields');
      $this->assertSession()->assertWaitOnAjaxRequest();
      $this->assertJsCondition('document.documentElement.style.overflow === "hidden"');
      $page->find('css', '.ui-dialog-buttonset')->pressButton('Apply');
      $this->assertSession()->assertWaitOnAjaxRequest();

      // Check overflow.
      $this->assertJsCondition('document.documentElement.style.overflow !== "hidden"');
    }
  }

}