Repository navigation
fix(BottomSheet): a finger's pull on the sheet's content is one touch drag from its touch-down, so a short flick closes the sheet - #11145
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
… drag from its touch-down, so a short flick closes the sheet A finger raises a pointer event before each touch event. The content's pointer handlers, which serve a mouse or a pen, armed for the finger too and began the drag first, at the same 8 px as the touch listeners. That drag took pointer capture for the content element. Moving the capture off the element under the finger raises lostpointercapture, which bubbles through the content and cancelled the drag one move later. The touch listeners then began the drag again with a new velocity tracker. In Chromium, whose pointer id is not the touch identifier, the touch listener found no touch for the pointer's drag, kept the move, and the content's own pan could start under the drag. The release speed counted only the moves after the drag began. A fast flick on the content that the page received as two or three moves read as no speed and sprang back, where the same flick on the grab handle closed the sheet. The content's touch-down now drops the pointer handlers' arm, so the touch listeners alone drag for a finger. The contact's positions are tracked from its touch-down, or its mouse press, and handed to the drag when it begins, as the grab handle's drag has them. No release threshold changes.
c819a8d to
d1e3f62
Compare
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| BottomSheet | 69.3 kB (+72 B) · 7.7 kB CSS (0) | — | ✗ · ✓ · — |
| BottomSheetSwitcher | 18.6 kB (0) · 3.4 kB CSS (0) | — | ✗ · ✓ · — |
| DateInput | 189.6 kB (+76 B) · 17.1 kB CSS (0) | — | — · — · — |
22 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DateTimeInput | 211.7 kB (+70 B) · 18.7 kB CSS (0) | — | — · — · — |
| PowerSearch | 292.8 kB (+67 B) · 24.2 kB CSS (0) | — | — · — · — |
| TimeInput | 164.8 kB (+67 B) · 16.1 kB CSS (0) | — | — · — · — |
| TableCell | 112.2 kB (+1 B) · 17.9 kB CSS (0) | — | — · — · — |
| ContextMenu | 111.0 kB (0) · 17.5 kB CSS (0) | — | — · — · — |
| DropdownMenu | 99.1 kB (0) · 17.6 kB CSS (0) | — | — · — · — |
| Markdown | 190.8 kB (0) · 20.8 kB CSS (0) | — | — · — · — |
| MoreMenu | 99.3 kB (0) · 17.6 kB CSS (0) | — | — · — · — |
| MultiSelector | 97.0 kB (0) · 16.9 kB CSS (0) | — | — · — · — |
| Pagination | 112.5 kB (0) · 17.8 kB CSS (0) | — | — · — · — |
| Popover | 93.0 kB (0) · 14.2 kB CSS (0) | — | — · — · — |
| Selector | 102.4 kB (0) · 17.4 kB CSS (0) | — | — · — · — |
| Table | 127.8 kB (0) · 18.4 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 111.8 kB (0) · 17.7 kB CSS (0) | — | — · — · — |
| Tokenizer | 94.5 kB (0) · 18.8 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 109.4 kB (0) · 1.1 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 154.4 kB (0) · 1.9 kB CSS (0) | — | — · — · — |
| lab/Comments | 355.5 kB (0) · 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) | — | — · — · — |
| lab/ChatEmojiPicker | 108.2 kB (−1 B) · 773 B CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 281.3 kB (−2 B) · 454 B 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 (+484 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
There was a problem hiding this comment.
Approved. A finger's pull on the sheet's content is now one touch drag from its touch-down, and the release counts the whole motion, which restores the touch-claim and release-velocity behavior the current records describe. The four new unit tests fail on main and pass here, and CI is green.
Nothing blocks. Two optional comment rewordings are left inline in useSheetGestures.ts. A pull that starts slowly on content that fits still does not move the sheet until #11140 lands.
| // Pointer path for the body at-top pull-down, for a mouse or a pen. A | ||
| // finger's drag belongs to the non-passive touch listeners below, so its | ||
| // touch-down drops this arm. |
There was a problem hiding this comment.
Optional wording (non-blocking): an Apple Pencil raises touch events too (see touchPointerType), so its touch-down also drops this arm. Suggested:
// Pointer path for the body at-top pull-down, for a contact that raises no
// touch events: a mouse, or a pen that raises none.| // A finger raises pointer events before its touch events, so the | ||
| // pointer path arms for it too. That path begins the drag first and | ||
| // takes pointer capture from the element under the finger. The capture | ||
| // change then cancels the drag. So a contact that raises touch events | ||
| // belongs to this path. |
There was a problem hiding this comment.
Optional wording (non-blocking): with the next line in place, the pointer path no longer begins the drag for a finger, so the present tense reads as current behavior. Suggested:
// A finger raises pointer events before its touch events, so the pointer
// path arms for it too. Its pointer capture would cancel the drag. This path
// owns every contact that raises touch events.





User impact
On a phone, a fast flick down on a sheet's content sometimes closes the sheet and sometimes springs it back. It springs back when the page receives the flick as two or three
touchmoves, which a short flick at a 60 Hz touch rate often is. The same flick on the grab handle closes the sheet every time. This affects BottomSheet and the sheets that Tokenizer and PowerSearch open (PowerSearch's Filters sheet, the Add filter sheet above it, and the value step above that).The same cause makes every pull on the content begin twice. The sheet's pointer handlers begin the drag, a pointer capture change cancels it one move later, and the touch listeners begin it again. On content that fits (the PowerSearch and Tokenizer sheets), a pull that starts slowly is not begun again: the sheet moves 10 to 20 px with the finger, returns to rest, and stays there while the finger keeps pulling. In Chromium the content's own pan can start under the drag.
Problem and solution fit
Why does it occur:
setPointerCaptureon the content element. A touch pointer is already captured by the element under the finger, so moving the capture raiseslostpointercaptureon that element. The event bubbles through the content, and the handler that guards a mouse drag cancels the drag one move later. Mobile Safari uses the touch identifier as the pointer id; Chromium uses another number, so there the touch listener finds no touch for the pointer's drag, keeps thetouchmove, and the content's native pan can start.Why does it harm the task: the same flick closes the sheet from the grab handle and not from the content, and whether it closes depends on how many moves the browser delivered, which a person cannot see. So a swipe down "sometimes works".
Why does it matter: a flick on the content is the most common way to dismiss a sheet on a phone.
The fix makes a finger's pull on the content one touch drag from its touch-down: the touch-down drops the pointer handlers' arm, and the contact's positions are tracked from the touch-down and handed to the drag when it begins.
Expected behavior and authority
spec:AST-094FR19: "A recognizer that begins MUST claim its touches by cancellingtouchmovethrough a non-passive listener on its element." The pointer handlers' drag left a finger'stouchmoveuncancelled in Chromium, and took the drag away from the listener that claims the touch.spec:AST-094FR36: "A drag that can commit an action MUST decide once, when the finger lifts." The pointer handlers' drag ended on a pointer capture change, with no lift.spec:AST-100FR2: "The velocity a component reads when the contact lifts is the velocity iOS reports for the same motion: a pan's velocity for a dragged surface." FR1: "components of the same kind report the same velocity for the same contact motion." FR4: "the same motion gives the same velocity for touch, pen, and mouse pointers."architecture:interaction-modalityINV10: one tracker "owns a gesture's pointer samples". A pull on the content read a different velocity from the same pull on the grab handle, whose tracker starts at the press.component:BottomSheetFR19 decides what a release does with that velocity (from 1,008 px/s a touch release is a flick, and "a flick at the lowest detent closes the sheet"). Those rules and their values are unchanged.No knowledge record changes: the records already state this behavior.
Smallest restoration
Two edits in
useSheetGestures.ts:touchstartlistener drops the pointer handlers' arm. A contact that raises touch events is the touch listeners' drag; a mouse or a pen, which raises none, keeps the pointer handlers.VelocityTrackerfrom the contact's start, andbeginDragtakes it. The grab handle's drag is unchanged: its tracker already starts at the press.No API, no visual change, no change to a threshold, the slop, the pan cancel, or the release rule.
Evidence
Setup: Storybook builds of
main(a21f2ee) and of this change. Playwright WebKit and Chromium on a 402 × 714 touch phone profile, with real touch input (WebKit's input command; Chromium CDP with scripted timestamps). Mobile Safari 27.0 in the iOS 27.0 simulator (iPhone 17) with HID swipes, formain. Sheets: a plain tall sheet whose list scrolls (core-bottomsheet--tall-sheet) and the three PowerSearch steps (core-powersearch--sheet-presentation): Filters, Add filter above it, the value step above that. Each sheet is 657 px tall on screen. Start points: the grab handle, the header, a row or the list, the footer. The page logged every pointer and touch event, eachsetPointerCapture, and the sheet's position per frame.1. A fast flick on the content, 150 px, sheets closed / flicks. The page read every flick at 1,700 px/s or more from the touch-down; a touch release is a flick from 1,008 px/s.
mainmain(In WebKit the Add filter row's point lands on the grab handle's band, so it is not a content start there.) Flicks of 4 or 5 moves close on both builds: WebKit 35/35 and 35/35, Chromium 40/40 and 40/40. A 2-move flick in Chromium closes on neither build (0/32 and 0/32): Chromium keeps the first
touchmoveinside its own touch slop from the page, so one move arrives and there is no velocity to read.2. Pointer capture on the content element, pulls and flicks that took it / all.
mainEach of them shows the same order on
main:pointermove(the pointer handlers begin the drag,setPointerCapture), thenlostpointercaptureon the element under the finger andgotpointercaptureon the content, then the touch listeners begin the drag again. In Mobile Safari the pointer id equals the touch identifier in all 19. In Chromium, 2 of the 136 ended inpointercancelwith 20 to 25 uncancelabletouchmoves under the drag; 0 with this change.3. A pull that starts slowly on content that fits (first moves 3, 6, 10, 15 px from the touch-down, or a 7 px first move in the simulator).
main, WebKit: 12 of 12 pulls on PowerSearch content moved the sheet 10 px, then the sheet sat at rest for 55 to 70 frames of the pull. 0 of 6 pulls of 420 px closed it.main, Mobile Safari in the iOS simulator: 7 of 8 moved the sheet 14 to 21 px and then it sat at rest for 32 to 72 frames of a 300 px pull; 1 never moved. The 6 pulls whose first delivered move was more than 8 px followed the finger. So did 5 of 5 on the plain tall sheet.useSheetGestures.test.tspasses with both applied (123 tests).mainplus that patch, 12 of 12 follow the finger and 6 of 6 close, but all still take pointer capture and are begun twice, and 2- and 3-move flicks still spring back (0/12). With that patch and this change: 12 of 12 follow, 6 of 6 close, 0 captures, and 2- and 3-move flicks close (12/12).Representative unchanged path. 187 scripted releases on the tall sheet and the Filters sheet (Chromium, from the grab handle and the content), compared pair by pair on the two builds, give the same result in 185. One of the two that differ is a 1,100 px/s content flick that the page received as three moves, which now closes. The other is a release from the grab handle, whose path this change does not touch, with a last sample 1 px back; it sits on the sign test of
spec:AST-094FR37 and went either way on both builds. On both builds:In WebKit, a
touchcancelduring a pull, a window blur during a pull, and a pull with the Add filter search field focused end the same way on both builds.Regression tests.
useSheetGestures.test.ts, four new cases that fail onmain: a finger that raises pointer events takes no pointer capture and keeps its pull throughlostpointercapture; a finger whose pointer id is not its touch identifier has every move cancelled; a content flick of two moves closes the sheet; a quick mouse pull from the content releases at the speed of the whole pull. One more case holds a slow two-move pull short of halfway open.BottomSheetBodyPull.interaction.browser.spec.ts, real touch input, in the pull request's interaction lane on both engines:mainStorybook: Chromium 3 of 3 fail, WebKit 2 of 2 fail. With this change: Chromium 3 of 3 pass, WebKit 2 of 2 pass.Scope
Components: BottomSheet
One defect: a finger's pull on the content was not one touch drag from its touch-down. A mouse or pen pull from the content takes the same tracker hand-off, so it also releases at the speed of the whole pull (
spec:AST-100FR4); its release rule is unchanged.Not in this change, measured and left as the records state them: a slow first move over content that fits (#11140); the release values; and FR37's rule that a release moving back toward the start cancels, whatever its speed. A last sample 1 px back was enough to return a 450 px pull in 17 of 22 trials across the two builds.
Testing
pnpm exec vitest run packages/core/src/BottomSheet packages/core/src/PowerSearch/PowerSearchBottomSheet.test.tsx(15 files, 785 tests)pnpm -F @astryxdesign/core typecheck,eslintandprettier --checkon the changed files,pnpm check:knowledge,pnpm review:pre(0 findings)pnpm exec playwright test -c playwright.interaction.config.ts BottomSheetBodyPullagainst a Storybook ofmain(Chromium 3 fail, WebKit 2 fail) and of this change (Chromium 3 pass; WebKit 2 pass, 1 skipped)main(19 pulls) and one pull on this change. An iOS Simulator run of this change is pending; Playwright WebKit covers it here.