-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
Description
🐛 Bug report
Current Behavior
Calling setFieldTouched runs validation on old values.
Expected behavior
Validation should be called on new values.
Reproducible example
https://codesandbox.io/s/formik-codesandbox-template-yqrgc
I can get around this issue with replacing
props.setFieldValue("name", "John");
props.setFieldTouched("name", true);with
props.setFieldValue("name", "John");
// Set `shouldValidate` to `false` to prevent validation
props.setFieldTouched("name", true, false);
// Call validation with the new values
props.validateField(name);Additional context
Related problems I could find: #1977, #2025
Your environment
| Software | Version(s) |
|---|---|
| Formik | 2.0.6 |
| React | 16.12.0 |
| Browser | Google Chrome 78 |
| npm/Yarn | Yarn 1.19.0 |
| Operating System | Fedora 31 |
njetsy, sentient-drone, rohitkrai03, straiki, nimiak and 53 moreNichtkunst, andycarrell, riiniii and techno199