Skip to content

fix(dismissable-layer): prevent escape from dismissing underlying layer - #4145

Open
dvd233 wants to merge 2 commits into
radix-ui:mainfrom
dvd233:fix/dismissable-layer-escape-race-4143
Open

dvd233 wants to merge 2 commits into
radix-ui:mainfrom
dvd233:fix/dismissable-layer-escape-race-4143

Conversation

@dvd233

@dvd233 dvd233 commented Sep 16, 2026 •

Copy link
Copy Markdown

Description

Fixes #4143.

When a new layer registers, the previous top layer can retain its keydown listener until React processes the layer update. An Escape press in that window could therefore be handled by the stale listener and dismiss the layer underneath.

This change keeps the render-time listener optimization, but verifies the current layer stack again at event time before invoking the Escape handlers. It also adds a deterministic regression test that dispatches Escape during child-layer registration and a patch changeset.

The synchronization commit 4493392536929a77864b3fca6cf29d34ed595be9 preserves the upstream IME Escape guard before the live layer-stack guard. The regression test merged without conflict and the original patch changeset remains.

Validation

On merge commit 44933925, with frozen-lockfile dependencies:

  • Dismissable Layer official unit suite: 36 passed.
  • Eight related consumer suites: 281 passed, 4 existing TODO, 0 failed (dialog, alert-dialog, context-menu, dropdown-menu, hover-card, popover, select and tooltip).
  • Package lint and typecheck passed; the same-dependency main typecheck also passed.
  • Canonical formatting checks for the two changed TSX files and contribution git diff --check passed.
  • The full repository suite, browser tests and build were not rerun on this merge. The previous 981-test/full-build validation belongs to the earlier head and is not reused as a check for this commit.

Upstream workflows currently require maintainer approval before execution; local validation does not establish that upstream CI passed.

AI-assisted follow-up validation and summary (GPT-6).

@changeset-bot

changeset-bot Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4493392

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@radix-ui/react-dismissable-layer Patch
@radix-ui/react-dialog Patch
@radix-ui/react-hover-card Patch
@radix-ui/react-menu Patch
@radix-ui/react-navigation-menu Patch
@radix-ui/react-popover Patch
radix-ui Patch
@radix-ui/react-select Patch
@radix-ui/react-toast Patch
@radix-ui/react-tooltip Patch
@radix-ui/react-alert-dialog Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-menubar Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

DismissableLayer 1.1.19: Escape during layer registration dismisses the layer underneath (stacked Dialogs both close)

1 participant