You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The repro contains 3 examples: Broky1, Broky2 & Worky. Switch the default between them to see the different behaviors.
Expected behavior
Since resetAfterSubmit is set, and the loader is returning random data, I would expect the input to update its value on each validation
Instead, the initial default value is kept
Screenshots or Videos
No response
Platform
OS: Linux
Browser: All
Additional context
No response
The text was updated successfully, but these errors were encountered:
I think this is the correct behavior. If reset always looked at looked at the latest defaultValues, there would no longer be a guarantee that it would actually reset to the expected values. And if resetAfterSubmit had different behavior than onSubmitSuccess={() => form.resetForm()} that would break expectations as well.
But I think this is worth clarifying in the docs.
We could potentially add first-calls support for this case by letting you specify something like resetAfterFormSubmit="reinitialize" or by adding a key to useForm that would reset & reinitialize.
I've added a Worky2 to the example that uses a remix Form, you'll see that it behaves as I would expect (updates the values)
IMO, the defaultValue of each field should always be up to date with the defaultValues of useForm, and thus the reset should always put back the latest defaultValues. This stays consistent with "vanilla react"
Is there any way to work around this currently, without implementing the whole fetch/submit flow manually? I can see that form.resetForm takes optional new values for the form, but with @rvf/remix's useForm, onSubmitSuccess doesn't seem to get called with the new data?
Edit: Managed to get Worky from above working, with the following code:
Which packages are impacted?
@rvf/react
@rvf/remix
@rvf/zod
@rvf/yup
zod-form-data
What version of these packages are you using?
Please provide a link to a minimal reproduction of the issue.
https://stackblitz.com/edit/stackblitz-starters-xtvc7x?file=app%2Froutes%2F_index.tsx
Steps to Reproduce the Bug or Issue
The repro contains 3 examples:
Broky1
,Broky2
&Worky
. Switch thedefault
between them to see the different behaviors.Expected behavior
Since
resetAfterSubmit
is set, and theloader
is returning random data, I would expect the input to update its value on each validationInstead, the initial default value is kept
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: