diff --git a/core/misc/dialog/dialog.position.js b/core/misc/dialog/dialog.position.js index 40bb5b6f038010aa35c38b6a68c10dda63684bbc..e3c058f8440aa25d9aa31508a3088cecca3d2e9a 100644 --- a/core/misc/dialog/dialog.position.js +++ b/core/misc/dialog/dialog.position.js @@ -100,11 +100,12 @@ $(window) .on('resize.dialogResize scroll.dialogResize', eventData, autoResize) .trigger('resize.dialogResize'); - $(document).on('drupalViewportOffsetChange', eventData, autoResize); + $(document).on('drupalViewportOffsetChange.dialogResize', eventData, autoResize); } }, 'dialog:beforeclose': function (event, dialog, $element) { $(window).off('.dialogResize'); + $(document).off('.dialogResize'); } }); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..19cf5a4b359aaa6fc905f887cff7722cd8e85ba8 --- /dev/null +++ b/core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php @@ -0,0 +1,52 @@ +drupalCreateUser(['administer blocks']); + $this->drupalLogin($admin_user); + $this->drupalGet('admin/structure/block'); + $session = $this->getSession(); + $assert_session = $this->assertSession(); + $page = $session->getPage(); + + // Open the dialog using the place block link. + $placeBlockLink = $page->findLink('Place block'); + $this->assertTrue($placeBlockLink->isVisible(), 'Place block button exists.'); + $placeBlockLink->click(); + $assert_session->assertWaitOnAjaxRequest(); + $dialog = $page->find('css', '.ui-dialog'); + $this->assertTrue($dialog->isVisible(), 'Dialog is opened after clicking the Place block button.'); + + // Close the dialog again. + $closeButton = $page->find('css', '.ui-dialog-titlebar-close'); + $closeButton->click(); + $assert_session->assertWaitOnAjaxRequest(); + $dialog = $page->find('css', '.ui-dialog'); + $this->assertNull($dialog, 'Dialog is closed after clicking the close button.'); + + // Resize the window. The test should pass after waiting for Javascript to + // finish as no Javascript errors should have been triggered. If there were + // javascript errors the test will fail on that. + $session->resizeWindow(625, 625); + $assert_session->assertWaitOnAjaxRequest(); + } + +}