Repository navigation
fix(cdk/a11y): disable configurable focus trap on destroy - #34215
Open
lxminarayn wants to merge 1 commit into
Open
lxminarayn wants to merge 1 commit into
lxminarayn wants to merge 1 commit into
Conversation
Destroying a ConfigurableFocusTrap deregistered it but left it enabled. A refocus queued by the event listener inert strategy just before destruction could then move focus back into the trap. The trap is now disabled when it is destroyed, so the pending refocus is skipped.
lxminarayn
force-pushed
the
fix/cdk-configurable-focus-trap-destroy
branch
from
December 3, 2026 03:02
3d34f8c to
b45ad2e
Compare
This branch has not been deployed
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.
ConfigurableFocusTrap.destroy()deregistered the trap but left it enabled. The event listener inert strategy refocuses the trap in asetTimeoutand skips the refocus only if the trap is no longer enabled, which is meant to cover code that moves focus out just before destroying the trap. Since the flag was never cleared, a refocus queued right beforedestroy()could still pull focus back into the trap's element.destroy()now disables the trap through the existingenabledsetter. The setter performs the same deregistration as before, so the trap stack, listener removal and anchor cleanup are unchanged, and the pending refocus is skipped.This only affects apps that use
ConfigurableFocusTrapFactory. Active traps behave the same and there is no public API change. A new spec inevent-listener-inert-strategy.spec.tsdestroys a trap while a refocus is pending and fails without this change.