fix(core): remove mount validation on touch #726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR closes #689
A few considerations:
When should we remove the errors?
My proposal would be to remove each field individually when gets touched and the form as soon as a field is touched.
As long as a field is not touched, it keeps the mount errors.
Should we be able to submit a form with onMount errors?
I'd say no, but currently if
state.submissionAttempts === 0 && !isTouched
we havecanSubmit: true
Adding
&& !hasOnMountError
also aims to fix the unwanted behavior described incanSubmit
is alwaystrue
on first render of form #723We might want to explicitly explain in the docs how we intend onMount to behave
I'm happy to improve the docs in this PR if we decide to go through with the proposed behavior
Bonus
The amount of eslint disable on form.errorsMap makes me wonder if we should consider it as optional in first place, but that's maybe another topic.