Skip to content

fix(dom): pass over elements that are not rendered when Tab moves focus - #20

Merged
adammharris merged 1 commit into
leaffrom
tab-skips-hidden
Oct 23, 2026
Merged

adammharris merged 1 commit into
leaffrom
tab-skips-hidden

Conversation

@adammharris

Copy link
Copy Markdown
Member

focus_next_node and focus_prev_node took any focusable element, so Tab
reached buttons inside a display: none element (a page's closed menus,
which unit keeps in the tree from the first frame) and visibility: hidden
ones. Nothing showed where focus went, and the accessibility tree, which
leaves such elements out, was handed a focus it did not contain, which
AccessKit panics on. A browser's sequential focus skips what is not
rendered; so does this.

Test: tab_order_tests::tab_passes_over_what_is_not_rendered. Independent of the a11y-modal branch, which separately makes the AX tree fall back to the window when focus is outside it.

`focus_next_node` and `focus_prev_node` took any focusable element, so Tab
reached buttons inside a `display: none` element (a page's closed menus,
which unit keeps in the tree from the first frame) and `visibility: hidden`
ones. Nothing showed where focus went, and the accessibility tree, which
leaves such elements out, was handed a focus it did not contain, which
AccessKit panics on. A browser's sequential focus skips what is not
rendered; so does this.

Behavioural-change: Tab and Shift-Tab no longer focus an element that is `visibility: hidden` or inside a `display: none` element.
@adammharris
adammharris merged commit a5db8a6 into leaf Oct 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant