script: Prevent invisible elements from being focusable#43431
Merged
Conversation
|
🔨 Triggering try run (#23253066704) for Linux (WPT) |
Contributor
Author
|
I forgot to mention that these are the results for the Linux WPT try run in my fork: https://github.com/jakubadamw/servo/actions/runs/23249269690. Fixing the commit sign-off issue now. |
Elements with `visibility: hidden` or `visibility: collapse` could receive focus via the JS `focus()` API, and already-focused elements did not lose focus when becoming invisible. Per the CSS Display spec, invisible elements "are removed from navigation." This adds a visibility check to `Element::focusable_area_kind()` so that invisible elements are excluded from all focusable area kinds. Signed-off-by: Jacob Adam <software@jacobadam.net>
Signed-off-by: Jacob Adam <software@jacobadam.net>
|
Test results for linux-wpt from try job (#23253066704): Flaky unexpected result (21)
Stable unexpected results that are known to be intermittent (20)
|
|
✨ Try run (#23253066704) succeeded. |
mrobinson
approved these changes
Mar 18, 2026
Member
|
@jakubadamw Let me know when you've signed-off on this commit and I will send it to the merge queue. |
Contributor
Author
|
@mrobinson, thank you for the review! Done. 🙂 |
Gae24
pushed a commit
to Gae24/servo
that referenced
this pull request
Mar 26, 2026
Elements with `visibility: hidden` or `visibility: collapse` could receive focus via both sequential navigation and the JS `focus()` API, and already-focused elements did not lose focus when becoming invisible. Per the CSS Display spec, invisible elements ”are removed from navigation”, which we can interpret to mean sequential focus navigation. In practical terms, all popular user agents also prevent elements with `visibility: hidden` from being focusable via click/the JS API, so this PR makes servo match that behaviour as well. Specifically, this adds a visibility check to `Element::focusable_area_kind()` so that invisible elements are excluded from all focusable area kinds. Fixes servo#41312. --------- Signed-off-by: Jacob Adam <software@jacobadam.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Elements with
visibility: hiddenorvisibility: collapsecould receive focus via both sequential navigation and the JSfocus()API, and already-focused elements did not lose focus when becoming invisible. Per the CSS Display spec, invisible elements ”are removed from navigation”, which we can interpret to mean sequential focus navigation. In practical terms, all popular user agents also prevent elements withvisibility: hiddenfrom being focusable via click/the JS API, so this PR makes servo match that behaviour as well.Specifically, this adds a visibility check to
Element::focusable_area_kind()so that invisible elements are excluded from all focusable area kinds.Fixes #41312.