Open aust1nz opened 2 months ago
Thanks for the codesandbox! I can reproduce the issue without Conform here.
Here is what happened:
Conform manages all uncontrolled inputs through a key
. When form reset happens, it forces react to unmount all inputs by updating the key
passed to them. If your cursor was focusing on one of the inputs, it will then lose the focus and trigger form validation by making a form submission with the validate intent. Normally, Remix will just capture the submit event and trigger a fetch request for you. But it becomes a document request in this case...
It's hard to tell what's really went wrong here because we are indeed abusing the keys right now 😅
Luckily, we are getting rid of the keys soon! I am planning to get #729 released in 1.2.0
. As we will no longer re-mount the inputs on form reset, it will not try to validate the form again and so the issue should be gone.
This is now working properly with v1.2.1. Thanks again!
Awesome, thanks for the update!
Describe the bug and the expected behavior
I've noticed some funny interplay between using Remix's useFetcher and conform's resetForm option, specifically when the useFetcher hits an action from another route. I've created a sandbox that shows this issue here:
https://codesandbox.io/p/devbox/interesting-hamilton-xt5pwn
Specifically, if the user fills out a name and hits enter to submit the form, they're brought to the JSON response that the action returns. Interestingly, if the user clicks the submit button, the form works as expected.
Conform version
1.1.5
Steps to Reproduce the Bug or Issue
https://codesandbox.io/p/devbox/interesting-hamilton-xt5pwn
Alternatively, create a basic Remix app with zod, @conform-to/react, and @conform-to/zod installed.
Update
routes/index.tsx
Create
routes/create-user.tsx
What browsers are you seeing the problem on?
Chrome
Screenshots or Videos
No response
Additional context
I suppose it's possible this is a Remix issue, but seems to specifically happen when the
submission.response({ resetForm: true })
option is configured.