-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting no validate or validationSchema clears out imperative error state on onBlur/onChange #834
Comments
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal. |
I don't think this is stale. I am curious if this behaviour is intended or whether it's a bug 🤔 |
I am experiencing the same problem and setting the third parameter "shouldValidate" on either setFieldTouched or setFieldError has not impact. The setFieldError places the error in the error collection; however, it is removed again before the final re-rendering. |
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal. |
ProBot automatically closed this due to inactivity. Holler if this is a mistake, and we'll re-open it. |
Hey guys, any updates on this? |
I get a similar issue when I try to I guess this issue because
Here prevState.errors and errors are different, and if they are different we return new errors object... @jaredpalmer , could you please help us here? |
@vtereshyn I'm also struggling with this specific problem atm. Can't use custom validators for other fields if I combine them in the same as s with validation Edit: Seems setFieldTouched is working as expected, if that's of any help |
@simon-nystrom , I resolved this problem using Field |
@vtereshyn how did you do that? I'm trying to combine |
@simon-nystrom , why you should use custom field without |
@vtereshyn you gave me an idea. Basically I'm integrating another third party library component with this and that component contains two input fields, but in this case I can consolidate the two errors to into one. This means I can use your approach and just combine the validate function to validate both fields. Thanks for the help. Works fine now 👍 |
@simon-nystrom , glad to help :) |
is this issue fixed? I am still facing this problem. I am using version 1.5.8 |
@jaredpalmer can you please help us to solve this problem |
Yeah I have the same problem. |
I'm still seeing this problem... |
Anyone managed to solve this? |
I think this needs to be reopened. |
@ImSolitude @val-samonte TBH I don't really think anybody gonna handle this, because this was reproducible in early 1.0.3 Formik version, which was in alfa at that time. And if I'm not mistaken it was fixed in 1.1 or some newer versions. |
This is still NOT fixed. Any solution? |
This is still happening in v2.2.9. Using |
So, for someone still finding this thread, you can just set |
This fix worked for me. |
@msnegurski what happens if one still needs that |
@inooid did you find any solution to this issue? |
@CalvinD3v honestly can't remember what I did to solve this. There are some ideas listed above though 👍 |
I still need to solve this problem 😐 |
this fixed the error trigger on blur. Thanks |
Hi @inooid
So Here we can use setStatus instead of setFiedError. |
added |
Current Behavior
Whenever you setup a Formik form and supply no
validate
orvalidationSchema
, but you callsetErrors
/setFieldError
as if it's coming from an API, it will clear out the entireerrors
object from Formik whenever you change or blur ANY field.Steps to Reproduce
See codesandbox for more info
Expected behavior
I would say whenever you apply no
validate
orvalidationSchema
, it should only clear out the error of the field you touched, not the entire form.Suggested solution(s)
I guess
onBlur
andonChange
validation should only clear out the field it is actually touching/changing.Additional context
Note: The Formik version of
0.11.11
does not clear theerrors
object on change or blur at all (which to me seems a bit more reasonable, since you explicitly set the errors yourself and there's not validation, so you'll have to manually clear them as well).Note: I haven't tested if this behaviour also happens whenever you do have a
validate
orvalidationSchema
setup.CodeSandbox Link:
https://codesandbox.io/s/pykpn4386m
The text was updated successfully, but these errors were encountered: