Skip to content

[drawer] Fix snap point jump when pinned pointer moves leave the drag offset unchanged - #5308

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/drawer-snap-points-glitch-d5d64d
Jul 23, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/drawer-snap-points-glitch-d5d64d

Conversation

@atomiks

@atomiks atomiks commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

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. handleMoveCore rewrote the raw (undamped) frozen transform and movement vars via syncDragStyles on every move, relying on the drawer's onProgress to overwrite them with the square-root-damped styles — but updateSwipeProgress dedupes unchanged deltas and skips onProgress for 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 syncDragStyles on 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.

@atomiks atomiks added component: drawer Changes related to the drawer component. type: bug It doesn't behave as expected. labels Jul 23, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5308
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5308
    

commit: 8d20d94

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+38B(+0.01%) 🔺+21B(+0.01%)

Details of bundle changes

Performance

Total duration: 1,208.84 ms +135.34 ms(+12.6%) | Renders: 78 (+0) | Paint: 1,879.62 ms +211.59 ms(+12.7%)

Test Duration Renders
Slider mount (300 instances) 133.17 ms 🔺+32.25 ms(+32.0%) 2 (+0)
Popover mount (300 instances) 73.66 ms 🔺+14.83 ms(+25.2%) 1 (+0)
Tooltip mount (300 contained roots) 57.12 ms 🔺+12.35 ms(+27.6%) 1 (+0)
Dialog mount (300 instances) 57.32 ms 🔺+12.31 ms(+27.3%) 1 (+0)

11 tests within noise — details

Metric alarms

Test Metric Change
Slider mount (300 instances) bench:paint 🔺 +52.96 ms
Popover mount (300 instances) bench:paint 🔺 +21.01 ms
Tooltip mount (300 contained roots) bench:paint 🔺 +19.37 ms
Dialog mount (300 instances) bench:paint 🔺 +19.63 ms

Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 8d20d94
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a6173ef2f6ae1000834ed8b
😎 Deploy Preview https://deploy-preview-5308--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks force-pushed the claude/drawer-snap-points-glitch-d5d64d branch from 30fa0e1 to 2853d05 Compare July 23, 2026 01:34
@atomiks atomiks changed the title [drawer] Fix snap point jump on duplicate-coordinate pointer moves [drawer] Fix snap point jump when pinned pointer moves leave the drag offset unchanged Jul 23, 2026
@atomiks
atomiks marked this pull request as ready for review July 23, 2026 01:40
@atomiks
atomiks requested a review from Copilot July 23, 2026 01:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) in handleMoveCore so 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.

@atomiks
atomiks merged commit 5df7708 into mui:master Jul 23, 2026
6 checks passed
@atomiks
atomiks deleted the claude/drawer-snap-points-glitch-d5d64d branch July 23, 2026 02:00
legowhales added a commit to legowhales/svelte-base-drawer that referenced this pull request Aug 13, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: drawer Changes related to the drawer component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants