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
[1.0.0] resetForm wipes out status #410
Comments
I have thought about this before but I am unsure whether it's a good idea to keep the status. Can you share your usecase with the success status here? |
The use case is displaying some form of feedback to the user that their form submission was successful (particularly when using a fetcher and not navigating anywhere).
The migration docs even say you can do it here: export default function Example() {
const lastResult = useActionData<typeof action>();
const [form, fields] = useForm({
// `lastSubmission` is renamed to `lastResult` to avoid confusion
lastResult,
});
// We can now find out the status of the submission from the form metadata as well
console.log(form.status); // "success", "error" or undefined
} But that isn't true, currently (as far as I can tell). |
I am also trying to figure out a way to do this. I opened up a discussion before I saw this. It would be very helpful to have access to the status and, in my case, have access to the previously mutated data so the user will get the proper feedback. |
I'm using the following workaround, but it feels pretty hacky. 🙂 return json({ ...submission.reply(), ...submission.reply({ resetForm: true }) }); |
Describe the bug and the expected behavior
Resetting a form via
return json(submission.reply({ resetForm: true }))
wipes out everything in the response data except for{ initialValue: null }
. This prevents us from checkinglastResult.status === 'success'
(orform.status
) to determine if the submission was successful.If you don't reset the form and just respond with
return json(submission.reply())
, thestatus
field is present and set tosuccess
as expected.Shouldn't
resetForm: true
just wipe out the data or whatever Conform needs to know to reset the form, but preserve thestatus
field (and possibly others if there are more that are unrelated to the form reset mechanic)?Conform version
v1.0.0
Steps to Reproduce the Bug or Issue
return json(submission.reply({ resetForm: true }))
useActionData().status
andform.status
areundefined
https://stackblitz.com/edit/remix-run-remix-vu7byk?file=app%2Froutes%2F_index.tsx
What browsers are you seeing the problem on?
Chrome, Firefox, Microsoft Edge, Safari, Others
Screenshots or Videos
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: