Skip to content

Conversation

@michaldudak
Copy link
Member

@michaldudak michaldudak commented Dec 29, 2025

mergeProps was already exported from the package, but not documented. As they are useful (shadcn components use it, for example), I added the docs page for them.
The docs were generated using an updated infrastructure, so the API definitions are taken from JSDocs (as in components) and not typed by hand.

Docs: https://deploy-preview-3642--base-ui.netlify.app/react/utils/merge-props

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 29, 2025

  • vite-css-base-ui-example

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

commit: 6962d36

@michaldudak michaldudak changed the title Document merge props [mergeProps] Make mergeProps public Dec 29, 2025
@mui-bot
Copy link

mui-bot commented Dec 29, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit c1cf29b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6952ebc2e373a500086884cf
😎 Deploy Preview https://deploy-preview-3642--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.

@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 22e5c86
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6952ec55c23e0000087edf3b
😎 Deploy Preview https://deploy-preview-3642--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.

@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 35221e6
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6952ed05e7227000082bf100
😎 Deploy Preview https://deploy-preview-3642--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.

@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 6962d36
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6953f6c41cabbb0008d89edf
😎 Deploy Preview https://deploy-preview-3642--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.

@michaldudak michaldudak marked this pull request as ready for review December 30, 2025 09:21
@michaldudak michaldudak requested a review from dav-is December 30, 2025 09:22
Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

LGTM. 👍
Thanks for addressing this. 🙏

michaldudak and others added 2 commits December 30, 2025 16:44
Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com>
Signed-off-by: Michał Dudak <michal.dudak@gmail.com>
...props
}: ParametersReferenceTableProps) {
return (
<PropsReferenceAccordion
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to abstract this into a <ReferenceAccordion/> component which both the parameters and props table would use?

```ts
mergeProps({ id: 'a', dir: 'ltr' }, { id: 'b' }); // returns { id: 'b', dir: 'ltr' }
```
Note that this includes refs.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the behavior most people would expect without diving deeper into why we don't merge the refs.
So I think it's worth being extra-explicit here and add a bullet point specifically for the ref 👍

Each argument can be a props object or a function that receives the merged props up to that point (left to right) and returns a props object.
This is useful when you need to compute the next props from whatever has already been merged.

When you return event handlers from a function argument, `preventBaseUIHandler()` is not applied automatically to those handlers.
Copy link
Member

Choose a reason for hiding this comment

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

A couple of code snippets on how to use the baseUIHandlerPrevented and preventBaseUIHandler() could be nice (with an object and with a function)

Comment on lines +30 to +33
- For React synthetic events, Base UI adds `event.preventBaseUIHandler()`. Calling it sets `event.baseUIHandlerPrevented = true`.
This does not call `preventDefault()` or `stopPropagation()`.
It only tells Base UI to skip earlier merged handlers or internal logic that checks the flag.
- For non-synthetic events (custom events with primitive/object values), this mechanism isn't available and all handlers always execute.
Copy link
Contributor

Choose a reason for hiding this comment

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

There's extra indentation here

Comment on lines +26 to +28
```ts
mergeProps({ onClick: a }, { onClick: b }); // b runs before a
```
Copy link
Contributor

Choose a reason for hiding this comment

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

The code blocks are missing a title, maybe the comments could be moved to the title

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: out-of-date The pull request has merge conflicts and can't be merged. public utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants