Skip to content

[button][select] Add support for async react action props#5136

Open
suneettipirneni wants to merge 8 commits into
mui:masterfrom
suneettipirneni:feature/implement-async-react-features
Open

[button][select] Add support for async react action props#5136
suneettipirneni wants to merge 8 commits into
mui:masterfrom
suneettipirneni:feature/implement-async-react-features

Conversation

@suneettipirneni

@suneettipirneni suneettipirneni commented Jun 28, 2026

Copy link
Copy Markdown

Closes #5133

Implements the actions paradigm for Select and Button. Some more can be added in the future, these components seemed to benefit the most.

The Async actions handbook page gives a good user-oriented overview as to why these props exist and what problems they aim to solve.

@pkg-pr-new

pkg-pr-new Bot commented Jun 28, 2026

Copy link
Copy Markdown

commit: e31ab54

@suneettipirneni suneettipirneni changed the title Add support for async react actions for controls [Field] Add support for async react actions for controls Jun 28, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 28, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+505B(+0.11%) 🔺+203B(+0.13%)

Details of bundle changes

Performance

Total duration: 1,098.22 ms -73.11 ms(-6.2%) | Renders: 78 (+0)

No significant changes — details


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

@netlify

netlify Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Built without sensitive environment variables

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

@suneettipirneni suneettipirneni changed the title [Field] Add support for async react actions for controls [Button][Select] Add support for async react action props Jun 28, 2026
@suneettipirneni suneettipirneni changed the title [Button][Select] Add support for async react action props [button][select] Add support for async react action props Jun 28, 2026
<div className={styles.Field}>
<Button
className={styles.Button}
clickAction={() => saveAction()}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The idea makes sense, but given the library supports React 17-19 I don't think we can have APIs that only work with React 19 though and degrades/doesn't work for other versions

(Not sure if it can be feature-detected either as startTransition exists in React 18 as well)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We can feature-detect this without relying on startTransition, since startTransition exists in React 18 too.

If we decide these props should be React 19-only, the runtime guard can check for React 19 action primitives instead, for example React.useActionState and/or React.useOptimistic. Those APIs are the meaningful signal here because clickAction / valueChangeAction are intended to integrate with React 19 action scheduling, not merely to run an async callback.

So the compatibility behavior could be:

  • if clickAction / valueChangeAction are not used, nothing changes;
  • if they are used with React 19, they work as intended;
  • if they are used with React 17/18, Base UI throws a clear runtime error recommending onClick / onValueChange instead or to upgrade to react 19.

That avoids version parsing and avoids using startTransition as an ambiguous signal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if they are used with React 17/18, Base UI throws a clear runtime error recommending onClick / onValueChange instead or to upgrade to react 19

My point is I don't think we can have an API that doesn't work ("throws a runtime error" = doesn't work) for a supported React version

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Makes sense. I’d be interested in hearing what the other maintainers think as well. If everyone agrees that we shouldn’t support this API until it works across all supported React versions, I’m happy to close this PR.

@suneettipirneni suneettipirneni marked this pull request as ready for review June 29, 2026 11:33
@aarongarciah aarongarciah added component: select Changes related to the select component. component: button Changes related to the button component. type: new feature Expand the scope of the product to solve a new problem. labels Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: button Changes related to the button component. component: select Changes related to the select component. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: First class support for async react primitives

3 participants