Skip to content
Snippets Groups Projects
Verified Commit 055e0831 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3397785 by yash.rode, srishtiiee, lauriii, smustgrave: Dialog focus is...

Issue #3397785 by yash.rode, srishtiiee, lauriii, smustgrave: Dialog focus is returned to dialog instead of first tabbable element on dialog AJAX update

(cherry picked from commit 762fcae9)
parent bc6752e6
No related branches found
No related tags found
18 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump,!5950Issue #3403653 by alexpott, longwave: Incorporate improvements to how contrib runs PHPStan to core,!5858Issue #3401971 by fjgarlin: Test-only job shouldn't require constant rebases...,!5716Draft: Issue #3401102 by Spokje, longwave, smustgrave: Nightwatch artifacts on GitLab not retained
Pipeline #59303 passed with warnings
Pipeline: drupal

#59324

    Pipeline: drupal

    #59321

      Pipeline: drupal

      #59312

        +1
        ...@@ -38,11 +38,16 @@ ...@@ -38,11 +38,16 @@
        $dialog.trigger('dialogButtonsChange'); $dialog.trigger('dialogButtonsChange');
        } }
        // If the body element has focus, it means focus was effectively lost. setTimeout(function () {
        // In these instances, force focus on the dialog. // Account for pre-existing focus handling that may have already moved
        if (document.activeElement === document.body) { // the focus inside the dialog.
        $dialog.dialog('widget').trigger('focus'); 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; const originalClose = settings.dialog.close;
        ......
        ...@@ -167,8 +167,12 @@ public function testDialog() { ...@@ -167,8 +167,12 @@ public function testDialog() {
        // Press buttons in the dialog to ensure there are no AJAX errors. // Press buttons in the dialog to ensure there are no AJAX errors.
        $this->assertSession()->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Hello world'); $this->assertSession()->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Hello world');
        $this->assertSession()->assertWaitOnAjaxRequest(); $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()->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Preview');
        $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->assertWaitOnAjaxRequest();
        $has_focus_text = $this->getSession()->evaluateScript('document.activeElement.textContent');
        $this->assertEquals('Do it', $has_focus_text);
        // Reset: close the form. // Reset: close the form.
        $form_dialog->findButton('Close')->press(); $form_dialog->findButton('Close')->press();
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment