Skip to content

[dialog] Fix popup prop merging #2119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2025
Merged

Conversation

atomiks
Copy link
Contributor

@atomiks atomiks commented Jun 16, 2025

With #2042, merging with main I noticed two issues:

  • nativeButton={false} must be specified on Dialog.Trigger since the Menu.Item is rendering it, which is not a native button (the keyboard handlers didn't work, only the pointer). I wonder if this can be made more obvious/clear.
  • The prop merging was incorrect in useDialogPopup, causing the onKeyDown handler to overwrite and break the handlers that handled the Escape event key bubbling

@atomiks atomiks added bug 🐛 Something isn't working component: dialog labels Jun 16, 2025
Copy link

pkg-pr-new bot commented Jun 16, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@2119

commit: e3589f7

@mui-bot
Copy link

mui-bot commented Jun 16, 2025

Bundle size report

Total Size Change: ▼-934B(-0.06%) - Total Gzip Change: ▼-191B(-0.04%)
Files: 41 total (0 added, 0 removed, 37 changed)

Show details for 41 more bundles

@base-ui-components/react/selectparsed: ▼-132B(-0.11%) gzip: ▼-15B(-0.04%)
@base-ui-components/react/scroll-areaparsed: ▼-126B(-0.79%) gzip: 0B(0.00%)
@base-ui-components/reactparsed: ▼-66B(-0.02%) gzip: 🔺+2B(0.00%)
@base-ui-components/react/alert-dialogparsed: ▼-58B(-0.11%) gzip: ▼-11B(-0.06%)
@base-ui-components/react/dialogparsed: ▼-58B(-0.11%) gzip: ▼-15B(-0.09%)
@base-ui-components/react/merge-propsparsed: ▼-22B(-1.40%) gzip: ▼-9B(-1.16%)
@base-ui-components/react/context-menuparsed: ▼-16B(-0.01%) gzip: ▼-4B(-0.01%)
@base-ui-components/react/menubarparsed: ▼-16B(-0.07%) gzip: ▼-6B(-0.08%)
@base-ui-components/react/navigation-menuparsed: ▼-16B(-0.02%) gzip: ▼-4B(-0.01%)
@base-ui-components/react/popoverparsed: ▼-16B(-0.02%) gzip: ▼-5B(-0.02%)
@base-ui-components/react/preview-cardparsed: ▼-16B(-0.03%) gzip: ▼-5B(-0.03%)
@base-ui-components/react/toastparsed: ▼-16B(-0.06%) gzip: ▼-5B(-0.05%)
@base-ui-components/react/tooltipparsed: ▼-16B(-0.03%) gzip: ▼-5B(-0.02%)
@base-ui-components/react/accordionparsed: ▼-15B(-0.06%) gzip: ▼-4B(-0.05%)
@base-ui-components/react/avatarparsed: ▼-15B(-0.22%) gzip: ▼-4B(-0.14%)
@base-ui-components/react/checkboxparsed: ▼-15B(-0.08%) gzip: ▼-4B(-0.06%)
@base-ui-components/react/checkbox-groupparsed: ▼-15B(-0.13%) gzip: ▼-5B(-0.11%)
@base-ui-components/react/collapsibleparsed: ▼-15B(-0.09%) gzip: ▼-7B(-0.11%)
@base-ui-components/react/fieldparsed: ▼-15B(-0.11%) gzip: ▼-3B(-0.06%)
@base-ui-components/react/fieldsetparsed: ▼-15B(-0.28%) gzip: ▼-4B(-0.17%)
@base-ui-components/react/formparsed: ▼-15B(-0.26%) gzip: ▼-5B(-0.20%)
@base-ui-components/react/inputparsed: ▼-15B(-0.14%) gzip: ▼-3B(-0.07%)
@base-ui-components/react/menuparsed: ▼-15B(-0.01%) gzip: ▼-4B(-0.01%)
@base-ui-components/react/meterparsed: ▼-15B(-0.22%) gzip: ▼-4B(-0.14%)
@base-ui-components/react/number-fieldparsed: ▼-15B(-0.05%) gzip: ▼-4B(-0.04%)
@base-ui-components/react/progressparsed: ▼-15B(-0.20%) gzip: ▼-5B(-0.17%)
@base-ui-components/react/radioparsed: ▼-15B(-0.10%) gzip: ▼-4B(-0.07%)
@base-ui-components/react/radio-groupparsed: ▼-15B(-0.07%) gzip: ▼-4B(-0.05%)
@base-ui-components/react/separatorparsed: ▼-15B(-0.37%) gzip: ▼-6B(-0.35%)
@base-ui-components/react/sliderparsed: ▼-15B(-0.06%) gzip: ▼-4B(-0.04%)
@base-ui-components/react/switchparsed: ▼-15B(-0.11%) gzip: ▼-4B(-0.07%)
@base-ui-components/react/tabsparsed: ▼-15B(-0.06%) gzip: ▼-4B(-0.04%)
@base-ui-components/react/toggleparsed: ▼-15B(-0.17%) gzip: ▼-5B(-0.14%)
@base-ui-components/react/toggle-groupparsed: ▼-15B(-0.10%) gzip: ▼-5B(-0.09%)
@base-ui-components/react/toolbarparsed: ▼-15B(-0.07%) gzip: ▼-4B(-0.06%)
@base-ui-components/react/use-renderparsed: ▼-15B(-0.39%) gzip: ▼-8B(-0.48%)
Base UI checkboxparsed: ▼-15B(-0.08%) gzip: ▼-5B(-0.07%)
@base-ui-components/react/direction-providerparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/unstable-no-ssrparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/unstable-use-media-queryparsed: 0B(0.00%) gzip: 0B(0.00%)
@base-ui-components/react/utilsparsed: 0B(0.00%) gzip: 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against e3589f7

Copy link

netlify bot commented Jun 16, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit e3589f7
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/685517214db2f100086fd8fb
😎 Deploy Preview https://deploy-preview-2119--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.

@atomiks atomiks force-pushed the fix/dialog-prop-merging branch from b554758 to 8042a9d Compare June 16, 2025 23:28
@atomiks atomiks marked this pull request as ready for review June 16, 2025 23:32
@@ -48,7 +48,7 @@ export default function MenuComplexNestingExperiment() {

<Dialog.Root>
<Menu.Item
render={<Dialog.Trigger />}
render={<Dialog.Trigger nativeButton={false} />}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem correct. Dialog.Trigger renders a native button. If there was <Dialog.Trigger render={<Menu.Item />}> we'd need nativeButton={false}.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it should be <Menu.Item render={<Dialog.Trigger />} nativeButton />, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, right - imo this area needs work in the API as it's pretty confusing and an easy footgun

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be alleviated by us using native buttons everywhere, including menu items. Then, only if devs want to use noninteractive elements, they'll have to explicitly add the prop.

@atomiks atomiks merged commit df20e0c into mui:master Jun 20, 2025
22 checks passed
@atomiks atomiks deleted the fix/dialog-prop-merging branch June 20, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working component: dialog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants