Skip to content

Conversation

@mj12albert
Copy link
Member

@mj12albert mj12albert commented Oct 19, 2025

Breaking: <Field>'s default validationMode is now 'onSubmit'.

  • validationMode can be set on <Form> to configure all child <Field>s
  • validationMode: 'onSubmit' runs validations when the <Form> is first submitted, afterwards fields are re-validated on change.

This mode matches native form submission behavior and the defaults of RA, Ariakit and react-hook-form.

Can be tested in the forms experiment though it's mostly required validations

Closes #2142

@mj12albert mj12albert added component: form Changes related to the form component. component: field Changes related to the field component. labels Oct 19, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 19, 2025

vite-css-base-ui-example

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

commit: cacb15a

@mui-bot
Copy link

mui-bot commented Oct 19, 2025

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 🔺+356B(+0.09%) 🔺+165B(+0.14%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Oct 19, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit cacb15a
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6901dc2dd393620008ddb679
😎 Deploy Preview https://deploy-preview-3013--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.

@mj12albert mj12albert force-pushed the form/submit-validation branch from 63c6d89 to 2d56111 Compare October 19, 2025 05:16
Comment on lines +199 to +208
* Asynchronous functions are supported, but they do not prevent form submission
* when using `validationMode="onSubmit"`.
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if it's a good idea to try to handle it, but its different from the native behavior anyway so I think we could just ignore and only document it for now, what do you think? @atomiks

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's possible to support it given event.preventDefault() needs to be sync, it makes sense to document it here

@mj12albert mj12albert force-pushed the form/submit-validation branch from 2d56111 to 7653f15 Compare October 20, 2025 07:45
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 21, 2025
@mj12albert mj12albert force-pushed the form/submit-validation branch from 7653f15 to 443266f Compare October 22, 2025 16:57
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 22, 2025
@mj12albert mj12albert force-pushed the form/submit-validation branch 14 times, most recently from e744eca to 730ccd2 Compare October 24, 2025 07:06
@mj12albert
Copy link
Member Author

Needs #3048

@mj12albert mj12albert force-pushed the form/submit-validation branch from 730ccd2 to ec66468 Compare October 24, 2025 18:31
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 27, 2025
@mj12albert mj12albert force-pushed the form/submit-validation branch from ec66468 to b19ec4a Compare October 27, 2025 15:20
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Oct 27, 2025
@mj12albert mj12albert force-pushed the form/submit-validation branch from b19ec4a to 090a2ac Compare October 27, 2025 19:20
@mj12albert mj12albert force-pushed the form/submit-validation branch from 090a2ac to 7eff286 Compare October 28, 2025 10:18
@mj12albert mj12albert force-pushed the form/submit-validation branch from ccf5a57 to 4339422 Compare October 28, 2025 13:24
@mj12albert mj12albert added the breaking change Introduces changes that are not backward compatible. label Oct 28, 2025
@mj12albert mj12albert marked this pull request as ready for review October 28, 2025 15:19
@mj12albert mj12albert requested a review from atomiks October 28, 2025 17:12
Copy link
Contributor

@atomiks atomiks left a comment

Choose a reason for hiding this comment

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

Nice~ matching RHF is a good default

@mj12albert mj12albert merged commit 8d78453 into mui:master Oct 29, 2025
20 checks passed
@mj12albert mj12albert deleted the form/submit-validation branch October 29, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. component: field Changes related to the field component. component: form Changes related to the form component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[form] Support validationMode: onSubmit

3 participants