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
FormStateInput
Form state not persisted
#466
Comments
This is a broader topic on whether Conform should persist server error and how. Conform does not persists any error by default and always use the last validation result (except when you are using async validation). The If I understand correctly, you expect the last server validation result to be persisted until the next server validation (To be precise, server validation with no other intent). Is this correct? |
After reading your explaination, the current behavior make sense. The server error isn't persisted since it isn't the last validation result. The client validation wouldn't give the same error, thus, no error state. Yeah, Here's two thoughts:
Or maybe I should just augment |
Either this or keep the form errors in a local state seems to me the only solution for now. const [form, fields] = useForm({
lastResult,
shouldRevalidate: 'onInput',
onValidate({ formData }) {
return parseWithZod(formData, { schema });
},
onSubmit() {
setFormErrors(undefined);
},
});
const [formErrors, setFormErrors] = useState<string[] | undefined>(
form.errors,
);
useEffect(() => {
if (typeof form.errors !== 'undefined') {
setFormErrors(form.errors);
}
}, [form.errors]);
// ... I was trying to put up another example utilizing the async validation mechanism to persist the error but I notice another issue that's make it hard to do with form error 😅 |
Conform will revalidate on blur only if there was any changes made before (i.e. an input event was triggered) to minimize the chance server error get cleared simply because of moving focus out of the inputs with v1.1.0-pre.0 |
Describe the bug and the expected behavior
After submitting a form resulting in a server error; performing form intents when utilizing
FormStateInput
should persist the form state.Conform version
v1.0.2
Steps to Reproduce the Bug or Issue
Submit form and receive error action result, see error state
Insert / remove fieldList item
Form error state is lost
What browsers are you seeing the problem on?
No response
Screenshots or Videos
screencast-vimeo.com-2024.02.20-15_29_46.webm
Additional context
I do not think this issue is specific to
v1.0.2
The text was updated successfully, but these errors were encountered: