Repository navigation
fix(core): focus trap DOM-depth Escape, aria-hidden exclusion, live-region clearing - #4375
Merged
Merged
Conversation
bhamodi
requested review from
cixzhang,
ejhammond and
imdreamrunner
as code owners
July 26, 2026 04:54
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
Contributor
|
It's crazy how simple announcements for a11y needs this complicated song and dance managing live regions. Thanks for handling these details. |
cixzhang
approved these changes
Jul 30, 2026
cixzhang
enabled auto-merge (squash)
July 30, 2026 06:15
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.
Summary
Three hardening fixes to the shared a11y hooks that back every overlay in the system (Dialog, Popover, menus, MobileNav), from a11y scan #3, plus a doc-only WCAG note on
useHotkeys:aria-hiddensubtrees (WCAG 4.1.2). A focusable element inside[aria-hidden="true"]was a Tab target in the trap cycle while assistive tech skips it, so keyboard focus could land on content that is invisible to AT.Changes
useFocusTrap.ts: the Escape stack now stores{handler, getContainer}entries.isTopEscapeHandlerwalks the stack in push order and keeps the DOM-deepest container as the top (if entry A's container contains entry B's, B is topmost), with push order as the tiebreaker for non-nested traps. Containers are read lazily at keydown time.hasActiveFocusTrapEscape()semantics are unchanged (Dialog still uses it for Escape deferral).useFocusTrap.ts:isVisiblyFocusablenow rejects elements matching or inside[aria-hidden="true"]viaclosest(), alongside the existinginert/hidden/computed-style checks. Runs per-Tab only.useAnnounce.ts: after each announce, a per-region timeout (2s, reset on every announce) clears the region text. ExplicitclearRegionand the test reset helper cancel pending timers. The clear-then-rAF re-announcement pattern is untouched; the delay comfortably outlasts the rAF re-set and test assertion windows.useHotkeys.ts: JSDoc note documenting the WCAG 2.1.4 (Character Key Shortcuts) obligation for unmodified single-character shortcuts — must be remappable, disableable, or focus-scoped. No behavior change.Test plan
onEscapeonly; after the inner unmounts, Escape falls back to the outeraria-hidden="true"are excluded fromfocusFirstand from the Tab wrap boundarynode_modules/.bin/vitest run packages/core/src/hooks --reporter=dot— 14 files, 183 tests passednode_modules/.bin/vitest run packages/core --reporter=dot— 222 files, 5165 tests, all passed (no announce-timing fallout, known Calendar/Typeahead flakes did not reproduce)node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit— cleaneslint+prettier --checkon changed files — cleannode scripts/check-changesets.mjs— 45 changesets validNotes