remix-validated-form
remix-validated-form copied to clipboard
[Bug]: Submitted data can get out of sync with invalidated data while async validating
Which packages are impacted?
- [X]
remix-validated-form
- [ ]
@remix-validated-form/with-zod
- [ ]
@remix-validated-form/with-yup
- [ ]
zod-form-data
What version of these packages are you using?
remix-validated-form
4.5.0
Please provide a link to a minimal reproduction of the issue.
https://codesandbox.io/s/wizardly-wozniak-1rho20?file=/app/routes/index.tsx
Steps to Reproduce the Bug or Issue
In the reproduction:
- Type a value into the input
- Click Submit
- Clear the input before validation is complete
By doing this, the submit will validate the data that was present when submit was clicked, but the form will actually submit the cleared input.
This reproduction is contrived, but it came up as a real issue on Discord. In that case, a fieldset
was being disabled when isSubmitting
was true, and that resulted in the data within the fieldset not being submitted.
Expected behavior
Ideally, we should capture the form values at the moment the user clicks submit.
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: Chrome
- Version: 101.0.4951.64
Additional context
Unfortunately, I think this is going to involve re-implementing some of the useSubmit
internals.
I'm happy to provide direction to anyone who might want to take a stab at fixing this. It could be a week or so before I have time to fix myself.