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

Simplify form reset on record change, and forward supported props from useAugmentedForm to useForm #8911

Merged
merged 2 commits into from
May 16, 2023

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented May 15, 2023

  • Leverage new feature in RHF allowing to call form.reset() automatically when the record (or defaultValues) change
  • Forward supported props from useAugmentedForm to RHF's useForm, the resetOptions in particular
  • Remove unused and undocumented hook useInitializeFormWithRecord

Additional info

Had to change the tests because this comes with a minor BC, in case the defaultValues change when there is no record:

  • Before: the form was not reset
  • Now: the form is reset
    => But the way I see it it's rather a bug fix than a BC, because I would expect changes in the defaultValues to be reflected in the form, regardless of the presence of a record.

@slax57 slax57 added the RFR Ready For Review label May 15, 2023
@@ -1119,7 +1119,7 @@ describe('<AutocompleteInput />', () => {
<SimpleForm
mode="onBlur"
onSubmit={jest.fn()}
defaultValues={{ role: 2 }}
defaultValues={{ language: 'ang' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me these tests have nothing to do with changing the defaultValues (I think it's a copy paste error), hence I changed that to keep the same defaultValues across rerenders.

@slax57 slax57 changed the title Simplify form reset on record change, and support custom resetOptions Simplify form reset on record change, and forward supported props from useAugmentedForm to useForm May 15, 2023
@djhi djhi added this to the 4.11.0 milestone May 16, 2023
@djhi djhi merged commit 495986a into next May 16, 2023
@djhi djhi deleted the Simplify-form-reset-on-record-change branch May 16, 2023 09:18
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.

2 participants