Description
- Before posting an issue, read the FAQ and search the previous issues.
Description
The error store does not automatically update when an error changes.
A form can only be submitted if all fields are error-free. However, in this library, the error state does not update to reflect new errors if we trigger a new one immediately.
Only happens when use:enhance is turned on
Steps to Reproduce
- Submit the form with an invalid field to trigger an error.
- Resolve the initial error.
- Trigger, at the same time a new error on the form.
Expected Behavior
The error store should update automatically to reflect the new errors.
Actual Behavior
The new error is not reflected in the UI, leading to inconsistencies.
This produces some weird side effects, like not reacting to errors when submitting the form for a second time
Workaround
A hacky workaround involves manually updating the error store using the onUpdate
option:
const { form, errors, message, enhance } = superForm(data.form, {
applyAction: true,
// Hacky way to FIX this
onUpdate: ({ form }) => {
$errors = form.errors;
},
});
If applicable, a MRE
Use this template project to create a minimal reproducible example that you can link to here: link to open in a new tab)