Skip to content

fix(BottomSheet): yield to a pinch whichever finger lands first - #7198

Merged
cixzhang merged 1 commit into
mainfrom
fix/bottomsheet-pinch-any-order
Oct 8, 2026
Merged

cixzhang merged 1 commit into
mainfrom
fix/bottomsheet-pinch-any-order

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

User impact

Follow-up to #7192. A pinch on an open BottomSheet now zooms the page, except when the fingers land in a particular order. If the first finger lands on the sheet's content and the second on the handle, the page does not zoom, and the sheet is dragged, or thrown away entirely (571px in real Chromium). Two other orders also moved the sheet: a lower finger first at the top of the content (24px), and a handle finger first with the second off the sheet (14px).

After this change, a pinch zooms the page and the sheet holds its detent, whichever finger lands first and wherever the second one lands.

Problem and solution fit

  • Why does it still drag? fix(BottomSheet): leave pinch-zoom to the browser #7192 disarmed the content's pull-to-collapse only when the second finger landed on the content. A second finger on the handle cancelled a drag in flight but left the content's armed pull in place. The content's pointer path ignored a second pointer altogether. As the fingers spread, the armed pull promoted into a sheet drag and preventDefault()ed the zoom away.
  • Why does that harm the task? The zoom fails, and the sheet can be dismissed by a gesture that was never a drag.
  • Why does it matter? WCAG 2.2 SC 1.4.4. A pinch must zoom regardless of finger order.

The fix is one hand-off, yieldToPinch. It drops every armed gesture (content touch, content pointer) and any drag in flight. It is called whenever a second finger shows up:

  • a non-primary pointer on the handle or the content;
  • a touch event on the content or the handle whose touches lists more than one finger, which catches a second finger off the sheet.

When the browser cancels a handle drag's pointer to take the pinch, the sheet now returns to its detent instead of settling from where the finger had got to.

Expected behavior and authority

Smallest restoration

  • useSheetGestures.ts: adds yieldToPinch, and wires it into the handle and content pointer-down, the content touch listeners, and new handle onTouchStart/onTouchMove. A handle pointercancel now calls cancelDrag.
  • One-finger behavior is unchanged: primary-pointer paths, release projection and the scroll hand-off are untouched.
  • The unreleased fix(BottomSheet): leave pinch-zoom to the browser #7192 changeset is reworded to cover every finger order. No new changeset.

Evidence

Real Chrome 155 (headless, phone emulation 390×844 @3×, CDP two-finger touch), core-bottomsheet--text-only. The table shows the most the sheet moved while the fingers were down:

Finger order Merged #7192 This PR
Handle, then content 0px, zooms 0px, zooms
Content, then handle 571px, sheet thrown 0px, zooms
Top of content, upper finger first 0px 0px
Top of content, lower finger first 24.5px 0px
Handle, then off the sheet 13.7px 6.8px, one input sample, then back to the detent
Content, sideways 0px 0px
  • Reproduction before the change: BottomSheetPinchZoom.a11y.chromium.spec.ts (now 6 finger orders plus the one-finger check) fails 2 of 7 against the merged fix(BottomSheet): leave pinch-zoom to the browser #7192 build.
  • Result after the change: 7 of 7 pass against this branch's build.
  • Representative unchanged path: the spec's one-finger handle drag and content scroll, and every existing useSheetGestures suite.
  • Regression tests: 5 new unit tests. All fail on the merged code and pass here:
    • content finger first, second on the handle;
    • a second finger off the content (touches > 1);
    • a second pointer on the content's pointer path;
    • a handle drag with a second finger off the sheet;
    • a browser-cancelled handle drag returns to its detent.

The one remaining transient (handle finger, then a finger off the sheet) is the browser's event order. The sheet cannot see a finger that lands off it until the handle finger's next touch event, and Chromium delivers that finger's pointermove first. The spec allows that one sample (under 16px) for that order only.

Scope

  • 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

A pinch whose first finger landed on the sheet body and whose second
landed on the handle (or off the body) could still promote the body's
armed pull into a sheet drag, cancelling the zoom and dragging or throwing
the sheet away. Route every second finger, on either surface and in either
order, through one hand-off that drops every armed gesture and any drag in
flight, and return a handle drag to its detent when the browser cancels it
to take the pinch.
@vercel

vercel Bot commented Oct 8, 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 Oct 8, 2026 10:49pm UTC

Request Review

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

astracat-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Oct 8, 2026, 11:05 PM UTC

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

@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.

Approving. Whichever finger lands first, the pinch now zooms and the sheet holds its detent; reproduced the thrown sheet and its fix.

  • Chrome 155 on a Linux rig, the committed spec run as-is against two Storybook builds from this head: with useSheetGestures.ts at the merged #7192 version, 2 of 7 fail — body finger first then handle moves the sheet 571px, lower finger first at the top of the body 24.5px — and the other five pass; at this head 7 of 7 pass, twice in a row, including the one-finger handle drag and content scroll.
  • Red arm: with the merged hook restored, the five new unit tests fail (body-first then handle; second finger off the body; second pointer on the body's pointer path; handle drag with a finger off the sheet; browser-cancelled handle drag returns to its detent) and the other 66 pass; at this head the hook file passes 71/71 and the BottomSheet directory 254/254.
  • Rewording the #7192 changeset is right: it is still unconsumed on main (no release since v0.6.6), so one note describes the behavior that ships. The 16px allowance applies only to the handle-then-off-sheet order and the spec says why.

[Automated review]

@cixzhang
cixzhang merged commit 59b2863 into main Oct 8, 2026
44 checks passed
@cixzhang
cixzhang deleted the fix/bottomsheet-pinch-any-order branch October 8, 2026 23:13
cixzhang pushed a commit that referenced this pull request Oct 24, 2026
## User impact

People who zoom a phone page to read it could not pinch-zoom from a list of swipeable rows: a pinch that started on an `Item` or `ListItem` with `swipeActions` did nothing, and in iOS Safari a sideways pinch swiped the row open. Such rows usually fill the screen.

Now that pinch zooms the page and the row stays put, whichever finger lands first. One-finger swipes and scrolling are unchanged.

## Problem and solution fit

- **Why does the pinch do nothing?** The row's `touch-action: pan-y` refuses pinch-zoom, and the swipe tracked only its first finger: a sideways pinch crossed the axis lock, so the row claimed it and cancelled `touchmove`.
- **Why does that harm the task?** The rows leave no other surface to pinch.
- **Why does it matter?** Zoom is how many readers resize text on a phone (WCAG 2.2 SC 1.4.4, AA).

## Expected behavior and authority

- `spec:AST-020` FR1 (current): WCAG 2.2 A and AA, so SC 1.4.4 Resize Text.
- `spec:AST-057` (current) is silent on `touch-action` and second fingers.
- As BottomSheet (#7192, #7198) and MobileNav (#7193).

## Smallest restoration

- `Item.tsx`: the swipe root declares `pan-y pinch-zoom`.
- `useSwipeAction.ts`: a second touch landing before the axis is decided, anywhere on the page (a document listener, only while that touch is undecided), hands the touch to the browser. A non-first pointer never starts a swipe. A swipe under way keeps its finger.

No new API, no visual change.

## Evidence

iOS 26.2 simulator, Safari, a pinch on the first row (to 2.5×): main stays at 1.00× and swipes the row open; this change zooms to 2.00×, the row still (`touch-action` `pan-y` → `pan-y pinch-zoom`).

![Main above: the row swipes open, no zoom. This change below: the page zooms, the row stays.](https://raw.githubusercontent.com/vjeux/astryx/d7aebf31d4333487b8300412e20670f7b7310c2b/item-swipe-pinch-zoom/ios-pinch.gif)

Chrome (phone emulation, CDP touch), zoom after the pinch, main → this change: sideways on the row 1.00× → 2.06× (row dragged 60 → 0 px); vertical across two rows 1.00× → 3.97×; one finger below the list, either order, 1.00× → 5.00×. `pinch-zoom` alone still dragged the row 15 px.

- Reproduction: `ItemSwipePinchZoom.a11y.chromium.spec.ts` fails 4 of 4 pinch cases on main; 4 of 5 new unit tests fail on main's code; all pass after.
- Unchanged: the one-finger case, `ItemSwipeActions.a11y.chromium.spec.ts`, the swipe unit tests; in iOS Safari a one-finger swipe still rests open.
- Regression tests: the spec and the unit tests (second finger on/off the row, non-first finger, owned swipe, listener lifetime).

## Scope

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

## Testing

- `pnpm exec vitest run packages/core/src/Item packages/core/src/List`: 159 passed.
- `pnpm exec playwright test packages/core/src/Item/__tests__ --project=chromium` against main's Storybook build and this branch's build, as above.
- iOS 26.2 simulator (iPhone 17 Pro), Safari, against both builds, as above.
- CI runs the new spec in its own pr-a11y step in `ci.yml`; `pnpm exec vitest run .github/scripts/ci-test-routing.test.mjs .github/scripts/release-check-workflow.test.mjs`: 101 passed.
- `pnpm -F @astryxdesign/core typecheck`, `pnpm check:changesets`, `pnpm check:sync`, `pnpm check:repo`; ESLint and Prettier on the touched files.

### Video per path

Chromium, real touch (CDP), main left, this change right; dots are a page overlay drawn from the page's touch events:

![Sideways pinch on a row, vertical pinch across two rows, one finger on the row and one below the list in either order: main swipes the row, this change zooms the page. A second finger while a swipe is under way: the swipe keeps its finger.](https://raw.githubusercontent.com/vjeux/astryx/d7aebf31d4333487b8300412e20670f7b7310c2b/item-swipe-pinch-zoom/chromium-pinch-paths.gif)

This branch was successfully deployed

1 active deployment
Preview — 26c1ca42 Deployed Oct 8, 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