Skip to content

fix(BottomSheet): a move of a touch drag no longer restyles the sheet's content - #11154

Merged
imdreamrunner merged 1 commit into
mainfrom
fix/powersearch-drag-jank
Nov 11, 2026
Merged

imdreamrunner merged 1 commit into
mainfrom
fix/powersearch-drag-jank

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Anyone who drags a BottomSheet with a finger. It was reported on PowerSearch's Filters sheet on a phone ("sometimes the drag down does not work, and it is janky"). This pull request takes the jank's largest measured cost. It holds for every sheet that owns its scrim: a single BottomSheet, or the first sheet of a stack, such as PowerSearch's Filters sheet and Tokenizer's sheet. main at a21f2ee has it, and so does @astryxdesign/core 0.7.13, whose BottomSheet source is the same.

Each move of a drag restyles every element in the sheet. A move writes the scrim's opacity on the dialog as --_sheet-scrim-opacity. Only the dialog's ::backdrop reads it, but a custom property inherits, so the browser restyles the dialog's whole subtree for each write. In desktop WebKit under load, one write and its style flush cost 2.8 ms for PowerSearch's Filters sheet with three filters (77 elements), 9.4 ms at 500 elements and 60 ms at 3,600. A sheet stacked above the first one (Add filter, the value step) does not own the scrim, writes nothing, and never paid this.

Problem and solution fit

Why does the restyle occur: the scrim's value travels to the backdrop through an inherited custom property set on the backdrop's originating element, and the sheet's content sits under that element. Why does it harm the drag: the style work runs on the main thread in the frame of every finger sample, and it grows with the content. Why does that matter: it is the largest single cost of a drag (50% of the drag's main-thread time in the first row of the trace table below, 17% after), paid on the device class where frames are scarcest.

The sheet's panel now declares --_sheet-scrim-opacity and --_sheet-scrim-duration as initial. The dialog and its backdrop keep the value. The panel's own computed style no longer changes when the dialog's value does, so both engines stop the restyle at the panel.

Not chosen: registering the property with inherits: false (the backdrop then cannot read it from the dialog without an explicit inherit, and StyleX emits no @property); writing the opacity through a Web Animation on ::backdrop (engine support for that pseudo-element is uneven); writing the scrim less often (the scrim would then step behind the finger).

Expected behavior and authority

No behavior change. The scrim follows the drag, fades with a drag's close and changes hands in a stack as before.

spec:AST-094 FR9 names the cost a move may have: "A drag MUST follow the finger with one visual update per move, with no component render per move and no layout read after the gesture begins." architecture:react-component-runtime INV18 holds a per-frame path to the same economy.

No record changes. No public API, markup, attribute or visual change. The two properties are private to BottomSheet (--_ names), and nothing under the panel reads them: a sheet opened inside another sheet's content writes its own on its own dialog.

Smallest restoration

Two declarations in the panel's style. Their two names join the theming guard's list of runtime variables that no theme sets (derivedVarRegistry.test.ts), because the guard reads every custom property a component's styles declare. The gesture code is untouched.

Evidence

Harness: Playwright phone profile (402 × 714, touch), real touch input through CDP in Chromium and the page proxy in WebKit, on PowerSearch's "Bottom sheet (forced)" story content and a plain Tall BottomSheet with the same structure (fixed header, a list in its own scroll viewport, a footer). Chromium runs at 4× CPU throttle. Pulls: "slow" starts slowly (cubic ease-in, 440 px in 900 ms, then a rest), "steady" is 320 px at 800 px/s.

Restyle per drag, Chromium DevTools trace, touch-down to lift (before → after)

sheet, start, pull elements restyled most in one recalc style time, ms main-thread time, ms
PowerSearch Filters, handle, slow 2,989 → 213 84 → 4 168.1 → 31.4 332.9 → 190.0
PowerSearch Filters, row, slow 1,924 → 187 84 → 21 79.2 → 36.8 201.3 → 172.2
PowerSearch Filters, gap under the rows, slow 1,739 → 224 84 → 67 92.3 → 42.0 218.6 → 171.6
PowerSearch Filters, footer, slow 2,065 → 337 84 → 67 109.7 → 33.6 264.9 → 158.5
PowerSearch Filters, handle, steady 1,360 → 82 84 → 4 63.4 → 13.0 131.1 → 87.1
plain Tall sheet, handle, slow 1,879 → 216 59 → 4 89.7 → 44.9 239.3 → 230.5
plain Tall sheet, row, slow 1,422 → 243 60 → 45 100.2 → 27.5 259.4 → 133.5

The recalcs that restyle more than 4 elements after the change are the press state of the touched control at touch-down and the release at the lift. The stacked sheets (Add filter, the value step) are the unchanged path: one element per move before and after, 13 to 213 elements per drag before and 9 to 214 after.

Cost of one scrim write and its style flush (200 writes, median of 5 runs, desktop engines on a loaded machine; the ratio is the result)

sheet WebKit before → after Chromium before → after
PowerSearch Filters, 77 elements 2.76 ms → 0.09 ms 0.41 ms → 0.05 ms
Tall sheet, 500 elements 9.43 ms → 0.18 ms 1.66 ms → 0.07 ms
Tall sheet, 3,620 elements 59.8 ms → 0.9 ms 14.0 ms → 0.06 ms

After the change the last element of the sheet reads no --_sheet-scrim-opacity in either engine, and the write's cost no longer grows with the content.

Drags that close the sheet, WebKit, per sheet step and start point (slow pull · steady pull, 2 runs each)

sheet start main this PR this PR + #11140 + #11145
PowerSearch Filters handle 2/2 · 2/2 2/2 · 2/2 2/2 · 2/2
PowerSearch Filters header 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
PowerSearch Filters row 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
PowerSearch Filters gap 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
PowerSearch Filters footer 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
Add filter, stacked handle 2/2 · 2/2 2/2 · 2/2 2/2 · 2/2
Add filter, stacked header 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
Add filter, stacked row 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
value step, stacked handle 2/2 · 2/2 2/2 · 2/2 2/2 · 2/2
value step, stacked header 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
value step, stacked row 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
plain Tall sheet handle 2/2 · 2/2 2/2 · 2/2 2/2 · 2/2
plain Tall sheet header 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
plain Tall sheet row 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
plain Tall sheet gap 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
plain Tall sheet footer 0/2 · 2/2 0/2 · 2/2 2/2 · 2/2
all 8/32 · 32/32 8/32 · 32/32 32/32 · 32/32

This change does not decide which pulls start a drag, and the table shows it leaves that alone. A slow pull on the content fails on main at every step and every start but the handle. That is the gesture's edge arming, which #11140 fixes; #11145 makes a finger's pull one drag. The last column has both applied on top of this branch: the three changes touch different lines and compose. React commits per closed content drag: 7 (7 to 9) on main, 8 (7 to 9) here, 5 (4 to 6) with all three. In Chromium every pull closed the sheet before and after (102 of 102 and 68 of 68), because Chromium holds back the first small touchmove.

Not measured on the iOS Simulator: I could not complete a simulator run of this branch in this session. The WebKit numbers above are desktop WebKit's, through Playwright.

Also measured on main in the PowerSearch sheets, with no defect found: no draft or typeahead state update per move (the only component that commits during a drag is the sheet's panel); no layout read per move after the drag starts (0 reads over 350 moves); no scroll-area measurement during a drag in any of the three sheets; with the Add filter search focused, a pull moves focus to the panel once, at its start. A software keyboard's close during a drag was not measured: the harness has none.

  • Representative unchanged path: the stacked sheets and every closing count above; the backdrop still follows the drag, fades with a drag's close and changes hands in a stack (BottomSheetScrimClock, BottomSheetDrag, BottomSheetRelease and the stacking suites pass).
  • Regression tests, each fails on main:
    • BottomSheet.test.tsx: "declares the dialog's scrim properties initial on the sheet panel". jsdom reports the declared value; the browser proof below covers the computed effect.
    • BottomSheetDragRestyle.interaction.browser.spec.ts (Chromium): no style recalculation between two moves of a drag restyles more than 6 elements. On main every move restyles 51.

Scope

Components: BottomSheet (BottomSheetPanel)

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run --project ui packages/core/src/BottomSheet packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx packages/core/src/Tokenizer/TokenizerBottomSheet.test.tsx packages/core/src/theme/derivedVarRegistry.test.ts: 17 files, 1,021 tests pass.
  • pnpm test:interaction BottomSheetDragRestyle: passes 3 of 3 runs on a Storybook built from this branch and fails 3 of 3 on one built from main.
  • pnpm test:interaction packages/core/src/BottomSheet on a Storybook built from this branch: 29 pass, 11 skip.
  • pnpm exec playwright test --config playwright.config.ts packages/core/src/BottomSheet packages/core/src/PowerSearch packages/core/src/Tokenizer on the same build: 179 pass, 1 skip. One timing proof ("a drag's close and its scrim's fade end together, at tempo 1") failed once in that run on a loaded machine and passes 20 of 20 alone, on this branch and on main.
  • pnpm -F @astryxdesign/core typecheck, ESLint and Prettier on the changed files, pnpm check:repo, pnpm review:pre (0 findings).

@vercel

vercel Bot commented Nov 11, 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 11, 2026 3:10am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 11, 2026, 3:27 AM UTC

@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 fix does what it says, but it turns a CI test red.

  • test-ui (1/4) fails at packages/core/src/theme/derivedVarRegistry.test.ts:477: the new '--_sheet-scrim-opacity' and '--_sheet-scrim-duration' keys in BottomSheetPanel.tsx read as undocumented component CSS variables, so add both to that test's STRUCTURAL_VARS with a one-line reason (runtime state the sheet writes on its dialog, never set by a theme).

In Chromium the sheet's content no longer inherits the scrim value, the backdrop still reads it, the frames are pixel-identical, and the new interaction proof passes in CI. Separately, the new unit test only checks that the declaration exists (jsdom echoes initial, while a browser computes it as empty), so consider naming it for what it checks.

Automated review (maintainer link)

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · aed3010

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
BottomSheet 69.3 kB (+38 B) · 7.7 kB CSS (+22 B) — ✗ · ✓ · —
BottomSheetSwitcher 18.6 kB (0) · 3.4 kB CSS (0) — ✗ · ✓ · —
DateInput 189.5 kB (+44 B) · 17.1 kB CSS (+27 B) — — · — · —
22 more components
Component Size LoC Visual · A11y · RTL
DateTimeInput 211.6 kB (+41 B) · 18.8 kB CSS (+28 B) — — · — · —
PowerSearch 292.8 kB (+38 B) · 24.3 kB CSS (+28 B) — — · — · —
TimeInput 164.7 kB (+27 B) · 16.1 kB CSS (+33 B) — — · — · —
Popover 93.0 kB (0) · 14.3 kB CSS (+32 B) — — · — · —
Table 127.8 kB (0) · 18.4 kB CSS (+30 B) — — · — · —
ContextMenu 111.0 kB (+1 B) · 17.5 kB CSS (+28 B) — — · — · —
TableCell 112.2 kB (+1 B) · 18.0 kB CSS (+28 B) — — · — · —
MultiSelector 97.1 kB (+1 B) · 16.9 kB CSS (+27 B) — — · — · —
Pagination 112.5 kB (0) · 17.8 kB CSS (+28 B) — — · — · —
Selector 102.4 kB (0) · 17.5 kB CSS (+28 B) — — · — · —
TableHeaderCell 111.8 kB (0) · 17.7 kB CSS (+28 B) — — · — · —
DropdownMenu 99.1 kB (0) · 17.6 kB CSS (+27 B) — — · — · —
MoreMenu 99.3 kB (0) · 17.6 kB CSS (+27 B) — — · — · —
Tokenizer 94.5 kB (0) · 18.9 kB CSS (+27 B) — — · — · —
Markdown 190.8 kB (−1 B) · 20.8 kB CSS (+27 B) — — · — · —
lab/ChatReactionBar 109.4 kB (+1 B) · 1.1 kB CSS (0) — — · — · —
lab/Comments 355.5 kB (+1 B) · 2.5 kB CSS (0) — — · — · —
lab/CommentThread 348.6 kB (0) · 2.4 kB CSS (0) — — · — · —
lab/TourStep 99.2 kB (0) · 590 B CSS (0) — — · — · —
richtext/RichTextEditorToolbar 281.3 kB (0) · 454 B CSS (0) — — · — · —
lab/ChatEmojiPicker 108.2 kB (−1 B) · 773 B CSS (0) — — · — · —
lab/CommentComposer 154.4 kB (−2 B) · 1.9 kB CSS (0) — — · — · —
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.30 MB packed (+252 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 68 rows, core 36 rows; run pnpm api:report.

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

…'s content

Each move of a touch drag writes the scrim's opacity on the dialog as a
custom property. Only the dialog's backdrop reads it, but the property
inherited into the sheet, so the browser restyled every element in the
sheet on every move. The panel now ends that inheritance: a move restyles
the dialog, its backdrop, the panel and the edge tint.

@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 panel now ends the scrim properties' inheritance, and the earlier test-ui (1/4) failure is fixed by the two STRUCTURAL_VARS entries.

  • In Chromium, a drag move's style recalculation drops from 51 elements to 4 in the Tall sheet story: the new interaction proof fails on the base and passes here, and the backdrop still follows the dialog's opacity with identical frames.
  • The visual report's BottomSheet change comes from an older baseline that predates the grab-bar inset fix (#8558); this branch and its base render the Text Only story identically.

Automated review (maintainer link)

@imdreamrunner
imdreamrunner merged commit 230d1b4 into main Nov 11, 2026
73 checks passed
@github-actions
github-actions Bot deleted the fix/powersearch-drag-jank branch November 12, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — aed30103 Deployed Nov 11, 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.

1 participant