Commit 054a7a64 authored by alexpott's avatar alexpott
Browse files

Issue #2731419 by hgoto, michielnugter, pareshpatel, tocab, Chernous_dn,...

Issue #2731419 by hgoto, michielnugter, pareshpatel, tocab, Chernous_dn, Sabbi0612, cilefen, droplet: "cannot call methods on dialog prior to initialization" logged when resizing after closing a modal
parent 68e01df0
...@@ -100,11 +100,12 @@ ...@@ -100,11 +100,12 @@
$(window) $(window)
.on('resize.dialogResize scroll.dialogResize', eventData, autoResize) .on('resize.dialogResize scroll.dialogResize', eventData, autoResize)
.trigger('resize.dialogResize'); .trigger('resize.dialogResize');
$(document).on('drupalViewportOffsetChange', eventData, autoResize); $(document).on('drupalViewportOffsetChange.dialogResize', eventData, autoResize);
} }
}, },
'dialog:beforeclose': function (event, dialog, $element) { 'dialog:beforeclose': function (event, dialog, $element) {
$(window).off('.dialogResize'); $(window).off('.dialogResize');
} }
}); });
namespace Drupal\FunctionalJavascriptTests\Dialog;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
* Tests the JavaScript functionality of the dialog position.
* @group dialog
class DialogPositionTest extends JavascriptTestBase {
* {@inheritdoc}
public static $modules = ['block'];
* Tests if the dialog UI works properly with block layout page.
public function testDialogOpenAndClose() {
$admin_user = $this->drupalCreateUser(['administer blocks']);
$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.');
$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');
$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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment