Repository navigation
[drawer] Fix snap point jump when pinned pointer moves leave the drag offset unchanged - #5308
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,208.84 ms +135.34 ms(+12.6%) | Renders: 78 (+0) | Paint: 1,879.62 ms +211.59 ms(+12.7%)
11 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
… offset unchanged
30fa0e1 to
2853d05
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a Drawer snap-point swiping glitch where duplicate/no-op pointermove events (common when the pointer is pinned at a screen edge during off-screen drags) could briefly reapply raw/undamped drag styles, causing visible “jumping” past the fully-open edge. The fix ensures raw drag style syncing only happens when the drag offset actually changes, and adds a regression test to cover duplicate-coordinate and ignored-axis jitter scenarios.
Changes:
- Gate
syncDragStyles(true)inhandleMoveCoreso it only runs when the computed drag offset changes, preventing raw style reinstatement on deduped moves. - Keep velocity sampling active on all moves via
recordDragSample, even when the offset is unchanged. - Add a Drawer viewport regression test ensuring damped snap-point styles remain stable across duplicate-coordinate moves and ignored-axis jitter.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/react/src/utils/useSwipeDismiss.ts |
Avoids rewriting raw drag styles when the drag offset didn’t change, preventing snap-point jump/glitch on pinned-pointer duplicate moves. |
packages/react/src/drawer/viewport/DrawerViewport.test.tsx |
Adds a regression test that reproduces duplicate-coordinate and ignored-axis jitter pointermoves and asserts damped styles remain applied. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ports the six applicable Drawer fixes from the base-ui v1.7.0 release: - mui/base-ui#5105: reliable swipe-to-open — first-move re-anchoring is now gated on trackDrag (the SwipeArea passes trackDrag: false, so a flick whose whole travel lands in the first move still registers), and sawPrimaryButtonsOnMove initializes from the event type. - mui/base-ui#5308: drag styles are only rewritten when the offset actually changed, fixing the snap point jump when the pointer is pinned at a screen edge. The swipeThreshold function is snapshotted at gesture start. - mui/base-ui#5257: cross-axis touch arbitration rewritten (shouldYieldTouchMove) — 6px slop / 2px bias, one-shot attribution per gesture, non-cancelable moves yield to native scroll, and no preventDefault until an axis passes the slop (iOS kills native scrolling for the whole gesture otherwise). - mui/base-ui#5360: elementFromPoint resolves through getRootNode() so swipe gestures work inside shadow DOM. - mui/base-ui#5112: the popup no longer flashes fully open for a frame during a swipe-area open — resetAfterOpen skips the movement-var reset while the SwipeArea drives the gesture (swipeAreaActive), and the SwipeArea re-asserts its styles when the popup (re)mounts. - mui/base-ui#5179: virtual keyboard scroll handling rework for focus moves while the keyboard is open — interval realign passes, preemptive focus geometry override to neutralize WebKit's reveal scroll, window scroll pinning, programmatic-focus flag, settle-watching scroll bookkeeping. The SwipeArea outside-press guard is now deterministic (capture-phase pointerdown/click listeners + isVirtualClick) instead of a 300ms timer. Not ported (React-only): mui/base-ui#5109, Drawer.Handle/createHandle detached triggers, bundle-size refactors. Co-Authored-By: Claude Fable 5 <[email protected]>
When a snap-point drawer is over-dragged past the fully-open edge and the cursor pins at the screen edge (an off-screen mouse drag), pointer moves keep arriving that don't change the drag offset — exact duplicates, or jitter on the horizontal axis that vertical-only drawers ignore.
handleMoveCorerewrote the raw (undamped) frozen transform and movement vars viasyncDragStyleson every move, relying on the drawer'sonProgressto overwrite them with the square-root-damped styles — butupdateSwipeProgressdedupes unchanged deltas and skipsonProgressfor exactly those moves. The raw styles then stuck, randomly jumping the popup to the undamped position and revealing the page below its bottom edge.The fix gates
syncDragStyleson the drag offset actually changing: a move that doesn't change the offset has nothing new to write, so the damped styles from the last processed move stay in place. Velocity sampling still runs on every move so release velocity decays correctly while the pointer is pinned.https://deploy-preview-5308--base-ui.netlify.app/react/components/drawer#snap-points - drag the drawer with a pointer way offscreen at the top. On 1.6.0/master it jumps/glitches, now it does not.