Skip to content

[dialog] Slim dialog root and dedupe default initial focus - #5034

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:dialog/slim-root-initial-focus
Jun 15, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:dialog/slim-root-initial-focus

Conversation

@atomiks

@atomiks atomiks commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Dialog-root simplifications (no behavior change):

  • Drop the redundant mergeProps(FOCUSABLE_POPUP_PROPS, dismiss.floating) — both popup consumers (DialogPopup/DrawerPopup) already spread FOCUSABLE_POPUP_PROPS directly.
  • Extract the shared touch default-initial-focus resolver into createDefaultInitialFocus, used by Dialog and Popover popups.
  • Make useDialogRoot return void and pass parentContext/isDrawer to DialogInteractions directly; drop the dead UseDialogRoot* interfaces and an eventTarget alias.

Adds a default touch initialFocus test.

@atomiks atomiks added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. component: dialog Changes related to the dialog component. internal Behind-the-scenes enhancement. Formerly called “core”. labels Jun 12, 2026
@pkg-pr-new

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

commit: 24e1e9e

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-174B(-0.04%) ▼-51B(-0.03%)

Details of bundle changes

Performance

Total duration: 1,248.14 ms +12.04 ms(+1.0%) | Renders: 50 (+0) | Paint: 1,870.66 ms +11.68 ms(+0.6%)

No significant changes — details


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

@netlify

netlify Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 24e1e9e
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2fa310fc26c700088f105f
😎 Deploy Preview https://deploy-preview-5034--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.

- Drop the redundant mergeProps(FOCUSABLE_POPUP_PROPS, dismiss.floating); both
  popup consumers (DialogPopup/DrawerPopup) already spread FOCUSABLE_POPUP_PROPS.
- Extract the shared touch default-initial-focus resolver into
  createDefaultInitialFocus, used by Dialog and Popover popups.
- Return void from useDialogRoot, pass parentContext/isDrawer to DialogInteractions
  directly, and drop the dead UseDialogRoot* interfaces and eventTarget alias.
- Add a default touch initialFocus regression test.
@atomiks
atomiks force-pushed the dialog/slim-root-initial-focus branch from bd2abb0 to d0a14b3 Compare June 12, 2026 07:22
@atomiks
atomiks requested a review from Copilot June 12, 2026 07:26

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 refactors shared popup/dialog internals to remove redundant prop merging, centralize the default touch initialFocus behavior, and simplify useDialogRoot’s API (no intended behavior change), while adding a regression test for touch-open focus behavior.

Changes:

  • Introduces createDefaultInitialFocus to dedupe the “touch opens: focus popup to avoid virtual keyboard” behavior across popups.
  • Simplifies dialog root wiring by making useDialogRoot return void and passing parentContext/isDrawer directly to DialogInteractions.
  • Removes redundant merging of FOCUSABLE_POPUP_PROPS into dialog popup props and adds a touch-focus test for Dialog.Popup.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/utils/popups/popupStoreUtils.ts Adds shared createDefaultInitialFocus helper for touch vs non-touch initial focus resolution.
packages/react/src/popover/popup/PopoverPopup.tsx Replaces inline touch initial-focus logic with createDefaultInitialFocus.
packages/react/src/dialog/root/useRenderDialogRoot.tsx Adjusts dialog root composition to call useDialogRoot for side effects and pass context flags into DialogInteractions.
packages/react/src/dialog/root/useDialogRoot.ts Simplifies useDialogRoot API, updates DialogInteractions props, and removes redundant popup prop merging.
packages/react/src/dialog/popup/DialogPopup.tsx Replaces inline touch initial-focus logic with createDefaultInitialFocus.
packages/react/src/dialog/popup/DialogPopup.test.tsx Adds coverage asserting touch-open focuses the popup instead of inner input content.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atomiks
atomiks marked this pull request as ready for review June 12, 2026 07:31
@atomiks
atomiks merged commit fe2101a into mui:master Jun 15, 2026
6 checks passed
@atomiks
atomiks deleted the dialog/slim-root-initial-focus branch June 15, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: dialog Changes related to the dialog component. internal Behind-the-scenes enhancement. Formerly called “core”. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants