Repository navigation
fix(BottomSheet): a move of a touch drag no longer restyles the sheet's content - #11154
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes requested: the fix does what it says, but it turns a CI test red.
test-ui (1/4)fails atpackages/core/src/theme/derivedVarRegistry.test.ts:477: the new'--_sheet-scrim-opacity'and'--_sheet-scrim-duration'keys inBottomSheetPanel.tsxread as undocumented component CSS variables, so add both to that test'sSTRUCTURAL_VARSwith 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.
PR Analysis Report🔎 Preview ·
|
| 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) | ![]() |
![]() |
![]() |
| BottomSheet · Text Only (neutral, light) | ![]() |
![]() |
![]() |
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.
816f13e to
aed3010
Compare
There was a problem hiding this comment.
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.






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.
mainat a21f2ee has it, and so does@astryxdesign/core0.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::backdropreads 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-opacityand--_sheet-scrim-durationasinitial. 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 explicitinherit, 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-094FR9 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-runtimeINV18 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)
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)
After the change the last element of the sheet reads no
--_sheet-scrim-opacityin 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)
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
mainat 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) onmain, 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 smalltouchmove.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
mainin 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.BottomSheetScrimClock,BottomSheetDrag,BottomSheetReleaseand the stacking suites pass).main:BottomSheet.test.tsx: "declares the dialog's scrim propertiesinitialon 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. Onmainevery move restyles 51.Scope
Components: BottomSheet (
BottomSheetPanel)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 frommain.pnpm test:interaction packages/core/src/BottomSheeton 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/Tokenizeron 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 onmain.pnpm -F @astryxdesign/core typecheck, ESLint and Prettier on the changed files,pnpm check:repo,pnpm review:pre(0 findings).