-
Notifications
You must be signed in to change notification settings - Fork 6
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
Prevent AutoForm validation with custom children to prevent being blocked unshown required fields #661
Prevent AutoForm validation with custom children to prevent being blocked unshown required fields #661
Conversation
packages/react/src/auto/AutoForm.ts
Outdated
const hasCustomChildren = !!props.children; | ||
const fieldPathsToValidate = hasCustomChildren | ||
? [] // With custom children, do not validate fields before sending them to avoid blocking submissions due to missing required fields | ||
: fields.map(({ path }) => path); |
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.
Should we use useMemo
to fieldPathsToValidate
with a [hasCustomChildren]
as the dep array?
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 call. Updated to add a useMemo
to avoid remapping on fields
"@gadgetinc/react": patch | ||
--- | ||
|
||
- Added an error message to AutoForm when passing in `include/exclude` options alongside child components |
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're throwing a hard error, so maybe it should be "Throw an error" instead.
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.
Updated to say that a new error is thrown
…cked unshown required fields
6a0b89a
to
d528d86
Compare
include/exclude
AutoForm propertiesAutoForm
will now avoid all local validations so that the requests are always sent to the server to be validated there.