Repository navigation
fix(overlays): topmost-only Escape dismissal + IME composition guard - #3357
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
18 of 30 tasks
cixzhang
marked this pull request as ready for review
July 2, 2026 15:14
cixzhang
requested review from
ejhammond,
imdreamrunner,
josephfarina,
marie-lucas,
nynexman4464 and
thedjpetersen
as code owners
July 2, 2026 15:14
josephfarina
approved these changes
Jul 2, 2026
thedjpetersen
approved these changes
Jul 2, 2026
useFocusTrap attached an unconditional document-level Escape listener per active trap, and Dialog added its own, so one Escape press closed every open layer (a popover nested in a Dialog closed both). CJK/IME users pressing Escape to cancel a composition also closed the overlay. Track active focus traps in a shared module-level stack so only the top-most trap responds to Escape; that handler now preventDefaults and stopPropagations so an outer Dialog does not also dismiss. Dialog defers to any active popover trap (hasActiveFocusTrapEscape) for topmost-only behavior, and both the trap and Dialog ignore Escape while an IME composition is in progress (isComposing / keyCode 229).
cixzhang
force-pushed
the
navi/fix/escape-stack-ime-guard
branch
from
July 2, 2026 18:45
5aa3e28 to
a9bb486
Compare
cixzhang
enabled auto-merge (squash)
July 2, 2026 19:01
This was referenced Aug 8, 2026
This branch was successfully 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.
Part of the accessibility & keyboard-management program (#3343). Fixes findings
overlays-2,overlays-3, andinfra-2.Problem
One Escape closed everything. Every active
useFocusTrapattached its own unconditional document-levelkeydownlistener, andDialogadded a separate one. So a single Escape press dismissed every open layer at once — e.g. a popover or menu opened inside aDialogclosed both the popover and the dialog.IME users lost their overlay. There was no composition guard on any Escape handler. A CJK/IME user pressing Escape to cancel an in-progress composition inside a
Dialogor popover closed the whole overlay (and their draft).Fix
useFocusTrapnow registers each active trap on a shared module-level stack. Only the most recently activated (top-most) trap responds to Escape; its handlerpreventDefault()s andstopPropagation()s so an outer layer does not also dismiss on the same press.DialogconsultshasActiveFocusTrapEscape()and defers to any popover/menu layered on top of it (in both thekeydownand nativecancelpaths), so the popover closes first and the dialog stays open.isImeKeyEvent()helper (isComposing/keyCode === 229) is applied in bothuseFocusTrapandDialog, so Escape during composition is ignored.The two new helpers (
hasActiveFocusTrapEscape,isImeKeyEvent) are internal cross-module utilities exported from the hook file and consumed byDialog; the publicuseFocusTrapAPI is unchanged.Tests
New direct unit tests for
useFocusTrap(the hook previously had zero):isComposingandkeyCode 229) is ignored, a normal Escape still works;Full Dialog, Popover, and CommandPalette suites pass (105 tests); core typecheck clean.