Skip to content
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

Fix Form should only trigger field validation on submit if not told otherwise #8826

Merged
merged 3 commits into from
Apr 13, 2023

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented Apr 11, 2023

Fix #8799

Todo

  • Fix
  • Test
  • Non-regression tests with EE components
  • Mention the related RHF rule in OSS docs

@@ -891,6 +891,13 @@ const PersonEdit = () => (
);
```

**Reminder:** [react-hook-form's `formState` is wrapped with a Proxy](https://react-hook-form.com/api/useformstate/#rules) to improve render performance and skip extra computation if specific state is not subscribed. So, make sure you deconstruct or read the `formState` before render in order to enable the subscription.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is weird as we don't use useFormState anywhere before or did I miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use the formState (formState: { isSubmitted }) so I figured I'd rather add the Reminder here anyway. But I'm open to discussion 😁

@@ -100,6 +100,13 @@ const LatLngInput = props => {
};
```

**Reminder:** [react-hook-form's `formState` is wrapped with a Proxy](https://react-hook-form.com/api/useformstate/#rules) to improve render performance and skip extra computation if specific state is not subscribed. So, make sure you deconstruct or read the `formState` before render in order to enable the subscription.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

@@ -146,3 +153,10 @@ const PersonEdit = () => (
</Edit>
);
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

@djhi djhi added this to the 4.9.3 milestone Apr 13, 2023
@djhi djhi merged commit 60155fe into master Apr 13, 2023
@djhi djhi deleted the fix-form-validate-on-submit branch April 13, 2023 07:58
@djhi djhi added the fix label Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

form validation function runs on on change for onSubmit forms
2 participants