Skip to content

[drawer] Handle CloseWatcher close requests from the cancel event - #5770

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/drawer-close-watcher-cancellation
Sep 22, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/drawer-close-watcher-cancellation

Conversation

@atomiks

@atomiks atomiks commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5767

The drawer closed from the CloseWatcher close event, which the browser only fires after destroying the watcher. Cancelling that close with eventDetails.cancel() left the drawer open with no watcher, so the next Android Back left the page.

The close request is now handled from the watcher's cancel event: onOpenChange(false) runs there, and a cancelled close calls preventDefault() so the same watcher stays active. This also stops the browser from processing other watchers in the same group. The browser only lets one close request per user activation be prevented; when the cancel event is not cancelable, eventDetails.cancel() is a no-op and the drawer closes like a native <dialog>. Controlled drawers can check eventDetails.event.cancelable to tell the two cases apart.

Tests use a stub that mirrors the browser's cancel → destroy → close sequence.

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

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

commit: 82d7a86

@code-infra-dashboard

code-infra-dashboard Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+79B(+0.02%) 🔺+23B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,075.54 ms -153.00 ms(-12.5%) | Renders: 76 (+0) | Paint: 1,792.68 ms -287.93 ms(-13.8%)

Test Duration Renders
Tabs mount (200 instances) 204.78 ms ▼-52.99 ms(-20.6%) 3 (+0)
Menu open (500 items) 69.84 ms ▼-31.51 ms(-31.1%) 11 (+0)
Menu mount (300 instances) 73.60 ms ▼-25.96 ms(-26.1%) 1 (+0)
Select open (500 options) 64.20 ms ▼-16.18 ms(-20.1%) 14 (+0)

11 tests within noise — details


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

@atomiks
atomiks marked this pull request as ready for review September 21, 2026 02:37
@netlify

netlify Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 82d7a86
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6ab1ec5d54d11f000870ce99
😎 Deploy Preview https://deploy-preview-5770--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 codex/drawer-close-watcher-cancellation branch from 0b63cf7 to 94d3fa6 Compare September 22, 2026 02:36
@atomiks atomiks changed the title [drawer] Restore CloseWatcher after canceled closes [drawer] Handle CloseWatcher close requests from the cancel event Sep 22, 2026
@atomiks
atomiks force-pushed the codex/drawer-close-watcher-cancellation branch from 94d3fa6 to 75720b6 Compare September 22, 2026 02:42
@atomiks
atomiks merged commit ffd74f5 into mui:master Sep 22, 2026
27 of 28 checks passed
@atomiks
atomiks deleted the codex/drawer-close-watcher-cancellation branch September 22, 2026 03:25
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] After eventDetails.cancel() on a close-watcher close, the next Back leaves the page

1 participant