Skip to content

fix(cdk/a11y): move focus to root if there are no focusable elements in focus trap - #33654

Merged
crisbeto merged 1 commit into
angular:mainfrom
crisbeto:33622/focus-trap-root
Aug 10, 2026
Merged

fix(cdk/a11y): move focus to root if there are no focusable elements in focus trap#33654
crisbeto merged 1 commit into
angular:mainfrom
crisbeto:33622/focus-trap-root

Conversation

@crisbeto

Copy link
Copy Markdown
Member

When focus lands on a focus trap anchor, it looks for focusable elements inside the root element, however if there are none, focus can escape the trap.

These changes include additional logic that will move focus to the root element, if it is focusable, and focus trapping didn't find any focusable descendants.

Fixes#33622.

@crisbetocrisbeto added the target: patch This PR is targeted for the next patch release label Aug 10, 2026
@pullapprove
pullapproveBot requested review from ok7sai and tjshiuAugust 10, 2026 07:38
…in focus trap
When focus lands on a focus trap anchor, it looks for focusable elements inside the root element, however if there are none, focus can escape the trap.
These changes include additional logic that will move focus to the root element, if it is focusable, and focus trapping didn't find any focusable descendants.
Fixesangular#33622.
@crisbeto
crisbetoforce-pushed the 33622/focus-trap-root branch from c0875d6 to 38a0b84CompareAugust 10, 2026 12:05
@crisbetocrisbeto added the action: merge The PR is ready for merge by the caretaker label Aug 10, 2026
@crisbeto
crisbeto merged commit f3e6276 into angular:mainAug 10, 2026
30 of 32 checks passed
@crisbeto

Copy link
Copy Markdown
MemberAuthor

This PR was merged into the repository. The changes were merged into the following branches:

crisbeto added a commit that referenced this pull request Aug 10, 2026
…in focus trap (#33654)
When focus lands on a focus trap anchor, it looks for focusable elements inside the root element, however if there are none, focus can escape the trap.
These changes include additional logic that will move focus to the root element, if it is focusable, and focus trapping didn't find any focusable descendants.
Fixes#33622.
(cherry picked from commit f3e6276)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: mergeThe PR is ready for merge by the caretakerarea: cdk/a11ytarget: patchThis PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Dialog): Dialog loses focus when it doesn't contain any focusable elements

2 participants

@crisbeto@ok7sai