-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add validation support for React Aria Components #5313
Conversation
Build successful! 🎉 |
mind rebasing this, looks like it has all the changes from #5288 as well |
4008b9a
to
9effbbb
Compare
Build successful! 🎉 |
validationErrors?: ValidationErrors | null | ||
} | ||
|
||
function Form(props: FormProps, ref: ForwardedRef<HTMLFormElement>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description says small wrapper and can add in the future, so I assume suggestions like providing data attributes and renderprops for focusWithin or a FormContext for passing in props would fall into that category of enhancements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good questions. I'm not sure what the use case for focus within on a form would be. I thought our recommendation was to use Group in those cases. I guess we could support FormContext for consistency but not really sure what people would use it for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I realized you could just use a Group, though don't know if it'd be a nice convenience feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do very explicitly say
All React Aria Components export a corresponding context that can be used to send props to them from a parent element
in our docs, just noticed
Build successful! 🎉 |
ah, didn't see the 2nd merge, looks like the tests need to be updated to have the new Item changes from the other PR. Will reapprove after that is updated |
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'any' } |
Depends on #5288
This adds support for the validation behaviors described in #5288 to React Aria Components. It includes two new components:
<FieldError>
renders form validation errors. It accepts render props to allow customization of the error messages.<Form>
is a small wrapper around an HTML<form>
that also supports thevalidationErrors
prop for server errors, which is provided via theFormValidationContext
. We could also potentially add more functionality here in the future (e.g. auto focusing the first invalid field).In addition, in RAC
validationBehavior="native"
is the default rather thanvalidationBehavior="aria"
. I think this is a better default, but we cannot change the behavior in RSP for backward compatibility reasons.