Skip to content

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

Open
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:dialog/slim-root-initial-focus
Open

[dialog] Slim dialog root and dedupe default initial focus#5034
atomiks wants to merge 1 commit 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

commit: d0a14b3

@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%) ▼-47B(-0.03%)

Details of bundle changes

Performance

Total duration: 1,255.72 ms -198.53 ms(-13.7%) | Renders: 50 (+0) | Paint: 1,898.34 ms -286.04 ms(-13.1%)

Test Duration Renders
Checkbox mount (500 instances) 69.30 ms ▼-44.79 ms(-39.3%) 1 (+0)

11 tests within noise — 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 d0a14b3
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2bb3bc949f5f0008bd9d53
😎 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
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