Skip to content

[drawer] Prevent dismiss through swipe when the component is controlled - #4133

Merged
flaviendelangle merged 12 commits into
mui:masterfrom
flaviendelangle:drawer-controlled-open
Mar 6, 2026
Merged

flaviendelangle merged 12 commits into
mui:masterfrom
flaviendelangle:drawer-controlled-open

Conversation

@flaviendelangle

@flaviendelangle flaviendelangle commented Feb 18, 2026 •

Copy link
Copy Markdown
Member

@flaviendelangle flaviendelangle self-assigned this Feb 18, 2026
@flaviendelangle flaviendelangle added type: bug It doesn't behave as expected. component: drawer Changes related to the drawer component. labels Feb 18, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 18, 2026 •

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

  • vite-css-base-ui-example

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

commit: 8884d68

@mui-bot

mui-bot commented Feb 18, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+210B(+0.05%) 🔺+74B(+0.05%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 025de78
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69aa8784dc96b40008a0cf24
😎 Deploy Preview https://deploy-preview-4133--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@flaviendelangle
flaviendelangle marked this pull request as ready for review February 18, 2026 13:20
@atomiks

atomiks commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Codex still found an issue with the latest change, but it resolved the broader issues with the DialogStore

PR #4133 latest review findings (2 issues)

Summary

The latest update narrows the fix to DrawerViewport, but one key regression appears to remain in controlled + snap points swipe-close behavior, and the tests still miss that path.

Details

  1. [P1] Controlled swipe-close is treated as canceled even when parent accepts close

    • In DrawerViewport.onDismiss, dismiss is force-canceled when !dismissEventDetails.isCanceled && store.select('open').
    • In controlled mode, store.select('open') is typically still true immediately after setOpen(false, ...) (before parent re-render), so this often cancels even accepted closes.
    • Canceled cleanup restores pendingSwipeCloseSnapPointRef, which can override the close-reset done in DrawerRoot.
    • Impact: controlled drawer with snapPoints can reopen at the previous snap point after a swipe close that parent actually accepted.
  2. [P2] Test coverage still misses accepted controlled close with snap points

    • Added test covers only “controlled and always open” (parent refuses close), with no snapPoints.
    • Missing: controlled + snapPoints + parent sets open=false on swipe.
    • That exact path is where the remaining regression is likely.

@atomiks

atomiks commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review

Overview

This patch fixes controlled drawer swipe-close behavior so a refused close no longer forces the drawer away, while an accepted close still resets snap points correctly. The latest follow-up also aligns the frame scheduling with the shared utility and removes repeated swipe-test setup.

Findings (None)

No blocking issues found in this patch.

Confidence: 4/5

High confidence from a full master...head pass and the added focused coverage for both rejected and accepted controlled swipe-close paths. Residual risk is limited to less common async controlled-close flows.

Notes

  • Latest changes since the previous review addressed the two earlier non-blocking notes: DrawerViewport now uses the shared animation-frame helper, and the swipe-dismiss tests now share a single environment setup helper.

@flaviendelangle

Copy link
Copy Markdown
Member Author

@atomiks done

@flaviendelangle
flaviendelangle merged commit cb584ec into mui:master Mar 6, 2026
6 checks passed
@flaviendelangle
flaviendelangle deleted the drawer-controlled-open branch March 6, 2026 08:02
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] Dismissible trough swipe in controlled mode

3 participants