Skip to content

fix(cdk/a11y): treat inert elements as non-focusable - #33846

Open
NoszDom wants to merge 1 commit into
angular:mainfrom
NoszDom:cdk-a11y-inert-focusable
Open

NoszDom wants to merge 1 commit into
angular:mainfrom
NoszDom:cdk-a11y-inert-focusable

Conversation

@NoszDom

@NoszDom NoszDom commented Sep 21, 2026

Copy link
Copy Markdown

InteractivityChecker.isFocusable ignored the inert attribute, so FocusTrap could pick an element inside an inert subtree as the first or last tabbable element. Calling focus() on such an element is a no-op, which left focus on the trap anchor and let Tab / Shift+Tab escape the trapped region.

Add an isInert check that walks the ancestors with closest('[inert]') and run it before the visibility check. The fix propagates through the shared checker to FocusTrap, ConfigurableFocusTrap, Dialog and FocusKeyManager.

StackBlitz demo of the bug: https://stackblitz.com/edit/cdk-trap-focus-with-inert?file=src%2Fmain.ts

`InteractivityChecker.isFocusable` ignored the `inert` attribute, so
`FocusTrap` could pick an element inside an inert subtree as the first or
last tabbable element. Calling `focus()` on such an element is a no-op,
which left focus on the trap anchor and let Tab / Shift+Tab escape the
trapped region.

Add an `isInert` check that walks the ancestors with `closest('[inert]')`
and run it before the visibility check. The fix propagates through the
shared checker to `FocusTrap`, `ConfigurableFocusTrap`, `Dialog` and
`FocusKeyManager`.
@pullapprove
pullapprove Bot requested review from ok7sai and tjshiu September 21, 2026 09:54
@google-cla

google-cla Bot commented Sep 21, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

1 participant