Skip to content

[drawer] Respect canceled snap point dismissal - #5571

Merged
atomiks merged 3 commits into
mui:masterfrom
radist2s:fix/drawer-canceled-snap-point-dismissal
Aug 26, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
radist2s:fix/drawer-canceled-snap-point-dismissal

Conversation

@radist2s

Copy link
Copy Markdown
Contributor

Fixes #5570

With snapPoints, a swipe dismissal first proposes null through onSnapPointChange. Consumers can cancel this change, but closeFromSnapPoints currently continues into the swipe release even when the event details are canceled.

This temporarily applies the popup's exit state and can request onOpenChange(false). When a controlled consumer rejects that close as well, the popup fades out before being restored to its previous snap point.

Reproduction

Both examples use the same controlled Drawer scenario and the same Base UI preview packages. The fixed example applies this change through a Yarn patch.

Steps:

  1. Wait for the Drawer to open at the collapsed snap point.
  2. Quickly drag the handle downward past the lowest snap point and release.
  3. Compare the popup behavior and the event log.

Before:

onSnapPointChange(null) canceled
onOpenChange(false) canceled
onSnapPointChange(0.26) accepted

The popup can briefly fade out before returning.

After:

onSnapPointChange(null) canceled

The canceled dismissal settles immediately without entering the exit state.

Changes

  • Check snapPointEventDetails.isCanceled immediately after proposing the null snap point.

  • Reset swipe progress and clear the release state when the proposal is canceled.

  • Return before storing a pending close snap point or starting the swipe release.

  • Add a regression test that verifies onOpenChange is not called and that neither data-ending-style nor data-swipe-dismiss is applied, including transient attribute changes.

  • I have followed (at least) the PR section of the contributing guide.

@pkg-pr-new

pkg-pr-new Bot commented Aug 25, 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@5571
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5571
    

commit: 656c799

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

Bundle size

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

Details of bundle changes

Performance

Total duration: 1,194.87 ms -16.93 ms(-1.4%) | Renders: 76 (+0) | Paint: 1,925.91 ms -57.76 ms(-2.9%)

Test Duration Renders
Combobox type — 500 items, narrows to ~11 (type "Row 25") 38.74 ms ▼-11.76 ms(-23.3%) 15 (+0)

14 tests within noise — details


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

@netlify

netlify Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 656c799
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a8e7e826280b50008727b72
😎 Deploy Preview https://deploy-preview-5571--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 added component: drawer Changes related to the drawer component. type: bug It doesn't behave as expected. labels Aug 26, 2026

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

Thanks for the fix @radist2s

@atomiks
atomiks merged commit f5823eb into mui:master Aug 26, 2026
7 checks passed
@radist2s

Copy link
Copy Markdown
Contributor Author

@atomiks, thank you so much for your prompt response! You’re brilliant, guys!

zernonia added a commit to unovue/reka-ui that referenced this pull request Sep 30, 2026
* fix(Drawer): let consumers cancel a swipe dismissal

A swipe that crossed the dismiss threshold committed on its own. A
controlled parent that ignored `update:open` left the drawer open but
offset by the swipe and marked `data-swipe-dismissed`.

Port Base UI's handling: `update:open` details now carry `cancel()` and
`isCanceled`. A canceled change keeps the drawer in its current state,
and a canceled swipe settles back to rest. A controlled `open` that is
still true on the next tick also undoes the dismissal. Snap-point
dismissals now report the `swipe` reason (mui/base-ui#5571).

Closes #2933

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* fix(Drawer): reset swipe progress when the drawer settles back

A swipe that ended with the drawer still open cleared the drag transform
but left the published swipe progress at its last value, so
`--drawer-swipe-progress` and nested/indent effects stayed dragged.
Publish zero progress whenever the drawer settles back, matching Base
UI's `settleInPlace`.

Also document that `v-model:open` writes the value even after
`details.cancel()`, and show the `:open` pattern for a controlled guard.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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.

[drawer] Canceling a null snap point change still starts swipe dismissal

2 participants