Skip to content

fix(Layer): a released kept-inside hold never makes its layer inert - #11684

Merged
cixzhang merged 3 commits into
mainfrom
l0/kept-inside-hold-release
Nov 15, 2026
Merged

cixzhang merged 3 commits into
mainfrom
l0/kept-inside-hold-release

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

User impact

  • Who: people who close a BottomSheet and open it again.
  • What can go wrong: a closing sheet's input hold reads focus a microtask after each focusout. If the hold is released between a focusout and that queued read, for example when the exit ends and focus returns to the trigger in one task, the read runs on a released hold and sets inert and aria-hidden on the sheet with nothing to remove them. The sheet opened again could then not take focus or input. The tests below reproduce that order. No browser flow is known to hit it today: in Chromium, Firefox and iOS Safari a reopened modal sheet and the Selector sheet stay usable.
  • After: a released hold never changes the layer, whatever the order.

Fixes #11646. Thanks to @jimmyallinai, who looked into #11646.

Why

A closing BottomSheet takes a 'kept-inside' input hold. The hold reads focus a microtask after each focusout. When focus returned to the trigger and the hold was released in the same task, that queued check ran after the release, found focus outside, and set inert and aria-hidden on the layer. Nothing removed them again.

What changed

  • Layer/inputHold.ts, holdKeptInside only: a released hold changes the layer no more. The queued focus check and the subtree watch both go through makeInert, which now returns once the hold is released.
  • [fix] changeset.

Evidence

  • inputHold.test.tsx "leaves the layer usable when its focus check runs after the release": the reporter's case. Focus inside, hold, move focus out, release in the same task, flush microtasks; the layer has no inert or aria-hidden. Fails on main, passes here.
  • BottomSheetCloseFocus.test.tsx "opens again usable after a close that returned focus to the opener": close the sheet from inside, let the exit end, open it again; the sheet is open with no inert or aria-hidden. Fails on main, passes here.
  • architecture:layer-runtime INV16 (current) decides the behavior: a released hold changes nothing.

Scope

  • One function, two tests and a changeset.
  • Public text contains no internal context.

Owner: Astryx fix-loop lane 0. Land path: CodeBunny approval of the exact head, Specs stamp, CI, then the merge queue (after #8373).

The hold reads focus a microtask after focusout. A release in the same
task ran first, and the queued check then set inert and aria-hidden on
the layer with nothing to remove them, so a BottomSheet opened again
could not take focus or input.
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 14, 2026 5:56pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 15, 2026, 12:30 AM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 40a8fbf

@cixzhang
cixzhang marked this pull request as ready for review November 14, 2026 04:57
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c680de8

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
BottomSheetSwitcher 18.7 kB (0) · 3.4 kB CSS (0) — ✗ · ✓ · —
LayerProvider 4.4 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
BottomSheet 73.0 kB (−3 B) · 7.7 kB CSS (0) — ✗ · ✓ · —
66 more components
Component Size LoC Visual · A11y · RTL
lab/CommentThread 361.5 kB (+11 B) · 2.4 kB CSS (0) — — · — · —
MoreMenu 107.0 kB (+5 B) · 18.6 kB CSS (0) — — · — · —
ContextMenuItem 35.1 kB (+2 B) · 6.9 kB CSS (0) — — · — · —
CommandPalette 79.1 kB (+1 B) · 12.7 kB CSS (0) — — · — · —
DateTimeInput 223.3 kB (+1 B) · 19.7 kB CSS (0) — — · — · —
Drawer 53.9 kB (+1 B) · 8.4 kB CSS (0) — — · — · —
Pagination 123.6 kB (+1 B) · 18.9 kB CSS (0) — — · — · —
PowerSearch 306.1 kB (+1 B) · 25.5 kB CSS (0) — — · — · —
lab/Comments 368.9 kB (+1 B) · 2.5 kB CSS (0) — — · — · —
BreadcrumbItem 96.2 kB (0) · 13.1 kB CSS (0) — — · — · —
ButtonGroup 44.1 kB (0) · 3.7 kB CSS (0) — — · — · —
CheckboxListItem 79.6 kB (0) · 11.9 kB CSS (0) — — · — · —
DropdownMenuCheckboxItem 28.3 kB (0) · 7.1 kB CSS (0) — — · — · —
DropdownMenuItem 27.5 kB (0) · 6.8 kB CSS (0) — — · — · —
DropdownMenuRadioItem 28.4 kB (0) · 7.1 kB CSS (0) — — · — · —
DropdownMenuSubMenu 79.1 kB (0) · 10.3 kB CSS (0) — — · — · —
Item 20.3 kB (0) · 6.0 kB CSS (0) — — · — · —
Lightbox 145.2 kB (0) · 11.9 kB CSS (0) — — · — · —
ListItem 78.8 kB (0) · 11.9 kB CSS (0) — — · — · —
Markdown 201.9 kB (0) · 21.7 kB CSS (0) — — · — · —
NavHeadingMenu 18.5 kB (0) · 3.5 kB CSS (0) — — · — · —
Popover 98.4 kB (0) · 15.1 kB CSS (0) — — · — · —
RadioListItem 75.8 kB (0) · 10.5 kB CSS (0) — — · — · —
SegmentedControl 102.0 kB (0) · 6.9 kB CSS (0) — — · — · —
SelectorOption 23.8 kB (0) · 6.6 kB CSS (0) — — · — · —
SideNavHeading 82.3 kB (0) · 12.1 kB CSS (0) — — · — · —
Slider 114.3 kB (0) · 8.9 kB CSS (0) — — · — · —
Switch 108.8 kB (0) · 10.0 kB CSS (0) — — · — · —
TabMenu 78.7 kB (0) · 11.9 kB CSS (0) — — · — · —
Toast 103.5 kB (0) · 11.1 kB CSS (0) — — · — · —
ToggleButton 91.9 kB (0) · 10.9 kB CSS (0) — — · — · —
ToggleButtonGroup 41.3 kB (0) · 3.7 kB CSS (0) — — · — · —
Tokenizer 103.5 kB (0) · 20.1 kB CSS (0) — — · — · —
TopNavHeading 81.9 kB (0) · 12.0 kB CSS (0) — — · — · —
TopNavMenu 81.3 kB (0) · 12.0 kB CSS (0) — — · — · —
lab/ChatVirtualizer 57.2 kB (0) · 223 B CSS (0) — — · — · —
lab/CommentComposer 162.5 kB (0) · 1.9 kB CSS (0) — — · — · —
lab/NavigationScreen 84.9 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/NavigationStack 84.9 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/PageControl 78.1 kB (0) · 709 B CSS (0) — — · — · —
lab/TabBar 83.5 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TabBarItem 3.9 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TabBarMoreList 101.6 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TransferList 111.8 kB (0) · 1.2 kB CSS (0) — — · — · —
lab/TransferListSelector 120.6 kB (0) · 1.4 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 299.3 kB (0) · 454 B CSS (0) — — · — · —
AlertDialog 128.5 kB (−1 B) · 15.4 kB CSS (0) — — · — · —
TableHeaderCell 121.3 kB (−1 B) · 18.7 kB CSS (0) — — · — · —
TimeInput 174.6 kB (−1 B) · 16.9 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 113.3 kB (−1 B) · 773 B CSS (0) — — · — · —
lab/ChatReactionBar 114.4 kB (−1 B) · 1.1 kB CSS (0) — — · — · —
AppShell 97.4 kB (−2 B) · 14.3 kB CSS (0) — — · — · —
DateInput 199.8 kB (−2 B) · 17.9 kB CSS (0) — — · — · —
MultiSelector 101.3 kB (−2 B) · 17.7 kB CSS (0) — — · — · —
Selector 112.6 kB (−2 B) · 18.5 kB CSS (0) — — · — · —
TableCell 121.6 kB (−2 B) · 18.9 kB CSS (0) — — · — · —
TopNav 77.9 kB (−2 B) · 11.7 kB CSS (0) — — · — · —
ContextMenu 120.3 kB (−3 B) · 18.4 kB CSS (0) — — · — · —
SideNav 121.1 kB (−3 B) · 12.2 kB CSS (0) — — · — · —
lab/Schedule 114.5 kB (−3 B) · 3.9 kB CSS (0) — — · — · —
MobileNav 76.1 kB (−4 B) · 11.4 kB CSS (0) — — · — · —
Table 138.5 kB (−4 B) · 19.4 kB CSS (0) — — · — · —
Dialog 25.5 kB (−5 B) · 6.9 kB CSS (0) — — · — · —
DropdownMenu 106.8 kB (−5 B) · 18.6 kB CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —
Visual changes: 2 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
BottomSheet · Text Only (neutral, dark) before frame after frame diff frame
BottomSheet · Text Only (neutral, light) before frame after frame diff frame

Package size: @astryxdesign/core 7.58 MB packed (+114 B); no new dependencies.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the guard is sound and both new tests fail before it and pass with it, but the release note describes a failure people did not see.

  • The changeset (.changeset/kept-inside-hold-release.md) and the description's "Who" and "Before" lines say a BottomSheet opened again after closing stayed inert and out of reach since 0.7.16, yet on main a modal sheet (mouse, reduced motion and touch) and the Selector bottom-sheet picker reopen usable with focus inside in Chromium, and in Firefox too, so please reword both to the race the tests reproduce: a release that lands between a focusout and its queued focus check, as when the exit and the focus return commit in one task under act().

A suggested changeset wording is on the changeset line, and an optional wording note on the new source comment is inline.

Claims and files checked
  • The hold reads focus a microtask after focusout, and before this change a check queued before the release could run after it and leave the layer inert: verified (inputHold.ts:606; the new test fails without the fix).
  • Nothing removed those attributes afterwards: verified (release() had already run, inputHold.ts:622-641).
  • Only holdKeptInside changes, and both the focus check and the subtree watch go through makeInert, which now returns once released: verified (inputHold.ts:554, :599-619).
  • The new inputHold test fails on main and passes here: verified.
  • The new BottomSheet reopen test fails on main and passes here: verified (fails at BottomSheetCloseFocus.test.tsx:302).
  • The layer-runtime record's input-hold rule decides the behavior: verified as a fair reading (the hold's inert applies while the layer dismisses).
  • The unguarded code shipped in 0.7.16: verified in the published package.
  • A reopened sheet was unusable for people in 0.7.16, including a touch picker: false in Chromium and Firefox on main (finding above).
  • After the change the sheet opens again fully usable: verified (tests and browser probes).
  • Fixes the linked issue: verified (its reproduction is the new inputHold test and its suggested guard is the fix).
  • One function, two tests and a changeset: verified.
  • No internal context in public text: verified.
  • Changeset, first sentence (a reopened sheet takes focus and input): true after the change, but it already did in browsers (finding above).
  • Changeset, second sentence (the closing hold could leave the sheet inert and hidden): true only when the exit commits in the same task as the focus return.
  • .changeset/kept-inside-hold-release.md: finding above.
  • packages/core/src/Layer/inputHold.ts: clear (optional comment wording).
  • packages/core/src/Layer/inputHold.test.tsx: clear.
  • packages/core/src/BottomSheet/BottomSheetCloseFocus.test.tsx: clear.

Automated review (maintainer link)

Comment thread .changeset/kept-inside-hold-release.md Resolved
Comment on lines +539 to +540
// A focus check queued before the release can run after it. A released hold
// changes the layer no more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: "changes the layer no more" is an idiom. A plainer version that keeps the reason:

// A focus check queued before the release can run after it. Then it must not
// change the layer.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b0fe991

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: the guard is sound, both new tests fail without it and pass with it, and the changeset now describes the race those tests reproduce. CI has not run its required checks on this head yet, because the CI workflow stopped with "CI is full"; re-run it (or push again) so build and tests run. The optional wording note on the new source comment in inputHold.ts still stands.

Claims and files checked
  • Changeset: a released input hold no longer changes its layer: verified (inputHold.ts:554; only the kept-inside hold ever wrote its layer after a release).
  • Changeset: a closing BottomSheet's hold reads focus shortly after focus leaves the sheet: verified (inputHold.ts:606, BottomSheet.tsx:888-892).
  • Changeset: a release in between could leave the sheet inert and hidden from assistive technology: verified (both new tests fail on main).
  • Changeset and description: no browser flow is known to hit it: consistent with the evidence; a modal sheet and the Selector bottom-sheet picker reopen usable on main in Chromium and Firefox; iOS Safari was not checked here.
  • The hold reads focus a microtask after each focusout: verified (inputHold.ts:606).
  • A release between a focusout and its queued read leaves inert and aria-hidden with nothing to remove them: verified on main (the new inputHold test fails at inputHold.test.tsx:1084).
  • The sheet opened again could then not take focus or input: verified in the test environment (the reopened sheet carries inert, BottomSheetCloseFocus.test.tsx:302).
  • After the change a released hold never changes the layer, whatever the order: verified (makeInert is the hold's only layer write and returns once released, inputHold.ts:553-561).
  • Fixes the linked issue: verified (its reproduction is the new inputHold test and its suggested guard is the fix).
  • A closing BottomSheet takes a kept-inside hold: verified (BottomSheet.tsx:888-892).
  • Only holdKeptInside changes, and the queued check and the subtree watch both go through makeInert: verified (inputHold.ts:599-619).
  • Both new tests fail on main and pass here: verified.
  • The layer runtime's input-hold rule decides the behavior: verified as a fair reading (the hold's inert applies while the layer dismisses).
  • One function, two tests and a changeset: verified.
  • Public text contains no internal context: verified.
  • .changeset/kept-inside-hold-release.md: clear.
  • packages/core/src/Layer/inputHold.ts: clear (optional comment wording).
  • packages/core/src/Layer/inputHold.test.tsx: clear.
  • packages/core/src/BottomSheet/BottomSheetCloseFocus.test.tsx: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 14, 2026 17:46
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c680de8

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: the guard in holdKeptInside is sound, both new tests fail without it and pass with it, and the changeset matches the race those tests reproduce. CI passed on this head. The optional wording note on the new source comment in inputHold.ts still stands.

Claims and files checked

Review mode: same-head; reason: none

  • Changeset: a released input hold no longer changes its layer: verified (inputHold.ts:586; the other hold kinds write their layer only while holding or releasing).
  • Changeset: a closing BottomSheet's hold reads focus shortly after focus leaves the sheet: verified (inputHold.ts:638, BottomSheet.tsx:888-892).
  • Changeset: a release in between could leave the sheet inert and hidden from assistive technology: verified (both new tests fail on main).
  • Changeset and description: no browser flow is known to hit it: consistent with the evidence; a modal sheet and the Selector bottom-sheet picker reopen usable on main in Chromium and Firefox; the iOS Safari result is the author's and was not checked here.
  • The hold reads focus a microtask after each focus loss: verified (inputHold.ts:638).
  • A release between a focus loss and its queued read leaves the sheet inert and hidden with nothing to remove them: verified on main (the new hold test fails at inputHold.test.tsx:1180).
  • The sheet opened again could then not take focus or input: verified in the test environment (the reopened sheet carries inert, BottomSheetCloseFocus.test.tsx:302).
  • After the change a released hold never changes the layer, whatever the order: verified (inputHold.ts:586, and release() restores only what the hold set, inputHold.ts:663-672).
  • Fixes the linked issue: verified (its reproduction is the new hold test and its suggested guard is the fix).
  • Only holdKeptInside changes, and the queued check and the subtree watch both go through makeInert: verified (inputHold.ts:631-651).
  • Both new tests fail on main and pass here: verified.
  • The layer runtime's input-hold rule decides the behavior: verified as a fair reading (the hold marks the layer only while the layer dismisses).
  • One function, two tests and a changeset: verified.
  • Public text contains no internal context: verified.
  • The land path waits on #8373: satisfied, it is on main.
  • Changed review rule, the review mode stated in plain text with no hidden comment: checked: this comment; no finding.
  • Changed review rule, the limits on a narrowed re-review: checked: the three rules changed since the last review; no finding.
  • Changed review rule, the reasons for a full review: checked: this review's mode; no finding.
  • .changeset/kept-inside-hold-release.md: clear.
  • packages/core/src/Layer/inputHold.ts: clear (optional comment wording).
  • packages/core/src/Layer/inputHold.test.tsx: clear.
  • packages/core/src/BottomSheet/BottomSheetCloseFocus.test.tsx: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 15, 2026 00:06
github-actions Bot added a commit that referenced this pull request Nov 15, 2026
@cixzhang
cixzhang merged commit fb91b76 into main Nov 15, 2026
154 checks passed
@github-actions
github-actions Bot deleted the l0/kept-inside-hold-release branch November 15, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — c680de82 Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A released 'kept-inside' input hold can still make its layer inert (closing BottomSheet stays inert)

1 participant