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

[drawer] Respect canceled snap point dismissal#5571
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

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
24 checks passed
@radist2s

Copy link
Copy Markdown
Contributor Author

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

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