Skip to content

fix(cdk/a11y): focus trap not finding tabbable elements in shadow DOM#33506

Open
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/issue_32265
Open

fix(cdk/a11y): focus trap not finding tabbable elements in shadow DOM#33506
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:fix/issue_32265

Conversation

@arturovt

@arturovt arturovt commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

FocusTrap walked the DOM tree using Element.children, which only returns light DOM children and never crosses into a nested element's shadow root. Custom elements (e.g. Lit-based components) that place their tabbable content in shadow DOM were invisible to _getFirstTabbableElement/_getLastTabbableElement, so the trap would skip over an entire region and its anchors would hand off focus to unrelated content instead of wrapping.

Walk into shadowRoot.children before children when a root has a shadow root, approximating shadow-including tree order.

Fixes #32265

FocusTrap walked the DOM tree using `Element.children`, which only
returns light DOM children and never crosses into a nested element's
shadow root. Custom elements (e.g. Lit-based components) that place
their tabbable content in shadow DOM were invisible to
`_getFirstTabbableElement`/`_getLastTabbableElement`, so the trap
would skip over an entire region and its anchors would hand off focus
to unrelated content instead of wrapping.

Walk into `shadowRoot.children` before `children` when a root has a
shadow root, approximating shadow-including tree order.

Fixes angular#32265
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.

bug(a11y): FocusTrap doesn't match browser/spec tab order in relation to Shadow DOM

1 participant