Loading core/misc/dialog/dialog.ajax.js +10 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,16 @@ $dialog.trigger('dialogButtonsChange'); } // If the body element has focus, it means focus was effectively lost. // In these instances, force focus on the dialog. if (document.activeElement === document.body) { $dialog.dialog('widget').trigger('focus'); setTimeout(function () { // Account for pre-existing focus handling that may have already moved // the focus inside the dialog. if (!$dialog[0].contains(document.activeElement)) { // Move focus to the first focusable element in the next event loop // to allow dialog buttons to be changed first. $dialog.dialog('instance')._focusedElement = null; $dialog.dialog('instance')._focusTabbable(); } }, 0); } const originalClose = settings.dialog.close; Loading core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -167,8 +167,12 @@ public function testDialog() { // Press buttons in the dialog to ensure there are no AJAX errors. $this->assertSession()->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Hello world'); $this->assertSession()->assertWaitOnAjaxRequest(); $has_focus_text = $this->getSession()->evaluateScript('document.activeElement.textContent'); $this->assertEquals('Do it', $has_focus_text); $this->assertSession()->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Preview'); $this->assertSession()->assertWaitOnAjaxRequest(); $has_focus_text = $this->getSession()->evaluateScript('document.activeElement.textContent'); $this->assertEquals('Do it', $has_focus_text); // Reset: close the form. $form_dialog->findButton('Close')->press(); Loading Loading
core/misc/dialog/dialog.ajax.js +10 −5 Original line number Diff line number Diff line Loading @@ -38,11 +38,16 @@ $dialog.trigger('dialogButtonsChange'); } // If the body element has focus, it means focus was effectively lost. // In these instances, force focus on the dialog. if (document.activeElement === document.body) { $dialog.dialog('widget').trigger('focus'); setTimeout(function () { // Account for pre-existing focus handling that may have already moved // the focus inside the dialog. if (!$dialog[0].contains(document.activeElement)) { // Move focus to the first focusable element in the next event loop // to allow dialog buttons to be changed first. $dialog.dialog('instance')._focusedElement = null; $dialog.dialog('instance')._focusTabbable(); } }, 0); } const originalClose = settings.dialog.close; Loading
core/tests/Drupal/FunctionalJavascriptTests/Ajax/DialogTest.php +4 −0 Original line number Diff line number Diff line Loading @@ -167,8 +167,12 @@ public function testDialog() { // Press buttons in the dialog to ensure there are no AJAX errors. $this->assertSession()->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Hello world'); $this->assertSession()->assertWaitOnAjaxRequest(); $has_focus_text = $this->getSession()->evaluateScript('document.activeElement.textContent'); $this->assertEquals('Do it', $has_focus_text); $this->assertSession()->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Preview'); $this->assertSession()->assertWaitOnAjaxRequest(); $has_focus_text = $this->getSession()->evaluateScript('document.activeElement.textContent'); $this->assertEquals('Do it', $has_focus_text); // Reset: close the form. $form_dialog->findButton('Close')->press(); Loading