question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onSubmit should or should not touch all fields anymore?

See original GitHub issue

Is 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:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
voroucommented, Jun 27, 2018

Hey, I’ve just bumped into current behavior (after the fix), and was pretty confused.

The doc says

true if this field has ever gained and lost focus. false otherwise.

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.

1reaction
erikrascommented, Mar 29, 2018

That’s very strange. Congrats! You’ve found a bug!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found