onSubmit should or should not touch all fields anymore?
See original GitHub issueIs it normal that the fields are not getting touched after we submit? In redux-form all the field were set to “touched”, this isn’t the case in final-form. Just wondering if this is intended or not? I think I like it, but the examples are miss-leading then.
In the following code pen you can enter directly a password without touching the username. Then the submit validation is running which will catch the missing/wrong username and will return the error. But the error isn’t shown because in all the examples the error is always in condition with meta.touched && ...
https://codesandbox.io/s/rmz7xmn44n
Any thoughts?
Edit: So the solution would be to change it from:
{(meta.error || meta.submitError) &&
meta.touched && <span>{meta.error || meta.submitError}</span>}
to
{(meta.error && meta.touched || meta.submitError)
&& <span>{meta.error || meta.submitError}</span>}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Formik sets touched to true for all fields during a submit attempt
I've got an issue where trying to submit this form brings up a warning as every field is being marked ...
Read more >No more tears, handling Forms in React using Formik, part I
As you can see above we need that added logic && touched.name to ensure errors are only shown when the field has actually...
Read more >How to use Forms in React - Robin Wieruch
You will learn how to manage form state in React, the difference of controlled and uncontrolled forms (state vs reference), how to submit...
Read more >Form Validation with JavaScript
Because we set our valid variable to false in any one of the above cases, if one or more of our checks fail,...
Read more >JavaScript Form Validation - The Art of Web
The purpose of a form validation script is to return a boolean value (true or false) to the onsubmit event handler. A value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, I’ve just bumped into current behavior (after the fix), and was pretty confused.
The doc says
and it didn’t mention failed submit at all.
What is the best way to get the behavior from the doc? Is there a different flag for this? I don’t actually care if the form was submitted or not, I only want to know if the user actually touched it.
That’s very strange. Congrats! You’ve found a bug!