Skip to content

Conversation

@mj12albert
Copy link
Member

@mj12albert mj12albert commented Oct 15, 2025

@mj12albert mj12albert added docs Improvements or additions to the documentation. component: form Changes related to the form component. labels Oct 15, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 15, 2025

vite-css-base-ui-example

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

commit: 8333cad

@netlify
Copy link

netlify bot commented Oct 15, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 8333cad
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/68ef75cdebcca500089e966d
😎 Deploy Preview https://deploy-preview-2983--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.

@mui-bot
Copy link

mui-bot commented Oct 15, 2025

Bundle size report

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

Details of bundle changes

Comment on lines +28 to +32
<Field.Error className={styles.Error} />

<Field.Error match={!!state.serverErrors.username}>
{state.serverErrors.username}
</Field.Error>
Copy link
Member Author

Choose a reason for hiding this comment

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

When returning errors with useActionState, passing them to the errors prop forces the validity state to be invalid: https://github.com/mui/base-ui/blob/master/packages/react/src/field/utils/getCombinedFieldValidityData.ts#L15

This blocks re-submitting the form for revalidation on the server (in the server fn) so the error gets stuck

});

return (
<Form className="flex w-full max-w-64 flex-col gap-4" action={formAction}>
Copy link
Contributor

Choose a reason for hiding this comment

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

onSubmit (or the internal effect from errors prop + submittedRef.current) handles focusing the first control with an error, which seems to be missing here. Does something else need to be done?

Copy link
Member Author

@mj12albert mj12albert Oct 15, 2025

Choose a reason for hiding this comment

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

Oh it's because I'm not passing the errors (assumed to be returned by a server/externally) to the errors prop #2983 (comment)

Maybe here: https://github.com/mui/base-ui/blob/master/packages/react/src/form/Form.tsx#L64
...could we assume that external errors via the errors prop are expected to be cleared externally (server-side) and shouldn't block submission? 🤔

Somewhat related - I'm not sure where onClearErrors should fit into all of this #2758

Copy link
Contributor

@atomiks atomiks Oct 15, 2025

Choose a reason for hiding this comment

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

could we assume that external errors via the errors prop are expected to be cleared externally (server-side) and shouldn't block submission? 🤔

I think this relates to Field.Root's validationMode prop - that makes sense for onSubmit but not onBlur and onChange? Maybe Form should be able to override all of their props with its own validationMode prop that you can set to onSubmit, in which case that behavior would make sense, because then if there are any errors it shouldn't block submission as the validation happens on submit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: form Changes related to the form component. docs Improvements or additions to the documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants