Skip to content

Commit adce845

Browse files
committed
Issue #3377900 by omkar.podey, lauriii, Gauravvvv, Utkarsh_33: Scrolling remains disabled after closing nested modal dialogs
1 parent 6c8c9f4 commit adce845

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

misc/dialog/dialog.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
function closeDialog(value) {
8787
$(window).trigger('dialog:beforeclose', [dialog, $element]);
8888
// Unlocks the body when the dialog closes.
89-
bodyScrollLock.unlock($element.get(0));
89+
bodyScrollLock.clearBodyLocks();
9090

9191
$element.dialog('close');
9292
dialog.returnValue = value;

modules/views_ui/js/dialog.views.js

-17
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,4 @@
8888
bodyScrollLock.lock($scroll.get(0));
8989
}
9090
});
91-
92-
/**
93-
* Binds a listener on dialog close to handle Views modal scroll.
94-
*
95-
* @param {jQuery.Event} e
96-
* The event triggered.
97-
* @param {Drupal.dialog~dialogDefinition} dialog
98-
* The dialog instance.
99-
* @param {jQuery} $element
100-
* The jQuery collection of the dialog element.
101-
*/
102-
$(window).on('dialog:beforeclose', (e, dialog, $element) => {
103-
const $scroll = $element.find('.scroll');
104-
if ($scroll.length) {
105-
bodyScrollLock.unlock($scroll.get(0));
106-
}
107-
});
10891
})(jQuery, Drupal, drupalSettings, bodyScrollLock);

modules/views_ui/tests/src/FunctionalJavascript/AdminAjaxTest.php

+22
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,26 @@ public function testAjaxRebuild() {
5959
$assert_session->pageTextContains('This is text added to the display edit form');
6060
}
6161

62+
/**
63+
* Tests body scroll.
64+
*/
65+
public function testBodyScroll() {
66+
$this->drupalGet('admin/structure/views/view/user_admin_people');
67+
$page = $this->getSession()->getPage();
68+
foreach (['name[views.nothing]', 'name[views.dropbutton]'] as $field) {
69+
$page->find('css', '#views-add-field')->click();
70+
$this->assertSession()->assertWaitOnAjaxRequest();
71+
$page->checkField($field);
72+
$this->assertSession()->assertWaitOnAjaxRequest();
73+
$page->find('css', '.ui-dialog-buttonset')->pressButton('Add and configure fields');
74+
$this->assertSession()->assertWaitOnAjaxRequest();
75+
$this->assertJsCondition('document.documentElement.style.overflow === "hidden"');
76+
$page->find('css', '.ui-dialog-buttonset')->pressButton('Apply');
77+
$this->assertSession()->assertWaitOnAjaxRequest();
78+
79+
// Check overflow.
80+
$this->assertJsCondition('document.documentElement.style.overflow !== "hidden"');
81+
}
82+
}
83+
6284
}

0 commit comments

Comments
 (0)