Skip to content

test: assert synchronous focus restoration except when outside click - #5913

Merged
web-padawan merged 2 commits into
mainfrom
test/overlay/assert-focus-restored-synchronously
May 31, 2023
Merged

web-padawan merged 2 commits into
mainfrom
test/overlay/assert-focus-restored-synchronously

Conversation

@vursen

@vursen vursen commented May 30, 2023 •

Copy link
Copy Markdown
Contributor

Description

The PR improves the overlay's focus restoration tests to assert that focus restores synchronously on overlay close except when an overlay closes on outside click. When clicking outside, Firefox and Safari force focus to move to the body element and retain it there until the next event loop iteration, so focus needs to be restored asynchronously but only in this particular case.

The target code fragment:

if (getDeepActiveElement() === document.body) {
// In Firefox and Safari, focusing the restoreFocusNode synchronously
// doesn't work as expected when the overlay is closing on outside click.
// These browsers force focus to move to the body element and retain it
// there until the next event loop iteration.
setTimeout(() => restoreFocusNode.focus());
} else {
restoreFocusNode.focus();
}

Follows up to #5881

Type of change

  • Internal

@vursen vursen changed the title test: assert synchronous focus restoration except when clicking outside test: assert synchronous focus restoration except when outside click May 30, 2023
@vursen
vursen marked this pull request as ready for review May 30, 2023 06:49
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 24.2.0.alpha1 and is also targeting the upcoming stable 24.2.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants