-
-
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
In v2-rc.9, isValid becomes true when not all required fields are filled in #1654
Comments
Reproduction would be probably very useful here. I tried CodeSandbox and it indeed does have some issue with RC9, but RC8 can be used. Can you try if you can reproduce the issue with that version? Also, any chance you are using |
My apologies. My sample in CodeSandbox (https://codesandbox.io/s/mystifying-leaf-j4hc6) works as expected without any problem. I probably have something in my existing code that doesn't translate well to v2. I'm closing this issue. I'll find what is at fault and if it is not on my side, I would re-open it. Sorry and thanks |
The issue does exist with v2.0.1-rc.9 but it does not with rc.8. I found the issue in my local environment using rc.9, but that one was not available in CodeSandbox. I have now downgraded my local environment to use rc.8 and now it works as expected, no problem. Something changed in between rc.8 and rc.9 that brought the reported problem. I am perfectly fine trying out rc.8, but you might want to know about the issue. |
The same place you got that screenshot from, npm. It might be wise to unpublish it after tracing its origin. |
Well as you can see in that screenshot, if you have installed Let's not nitpick in this, I am sure it was just an honest mistake and RC10 will be just fine :) |
RC9 was a test and isn't stable |
I wonder if switching to |
@jaredpalmer It's probably better to be releasing tests with a different ID than RC ;) Can you at least point out to some branch or PR which is RC9 about? Hard to track what got broken otherwise. |
It’s the debounce pr but I don’t think it built properly tbh |
Try rc10 |
@jaredpalmer One essential problem with
It's a major pain for big forms to be forcing full schema when only a couple of fields need to be actually validated. There is a TypeScript to tackle typos and stuff. |
Same behavior in rc.10 as with rc.9, except that rc.10 can now be loaded successfully in CodeSandbox: https://codesandbox.io/s/mystifying-leaf-j4hc6. The submit button gets enabled as soon as you type something in the first field, even though both are mandatory. |
@jaredpalmer I wonder how did you solve the #1654 (comment)? Looking at current master, the Line 205 in dce8d31
|
🐛 Bug report
For Formik v2.01-rc.9. isValid becomes true even if not all required fields are filled in.
Current Behavior
If you have a form with two fields and a Yup schema with both fields declared as required, once you type something valid on the first field,
isValid
turns true, since the second field, empty but untouched, doesn't get validated.As I have the Submit button disabled when
isValid
anddirty
are false, the user gets the wrong impression that the form is ready to submit. It eventually rejects the submission, and shows the error message, but the user is getting the wrong impression, after all, the interface enabled the submit button.If you do start filling the second field, the submit button remains enabled but if you then backspace until the field is empty, the submit button gets disabled, as it should, and should have been the first time around as well.
Expected behavior
With v1, I used
isInitialValid
which forced all fields to be changed, and thus validated, before isValid becomes true.Currently, I am using
initialErrors
with empty string on those required fields so, on the one hand,isValid
is false and the error text, being an empty string, is falsy and doesn't distract the user with spurious error messages. (Actually, I getinitialErrors
filled in based on what I get from analyzing whatschema.describe
and checking for required fields)Reproducible example
Sorry, codesandbox seems to be unable to fetch v2.0.1-rc.8 or 9. Most likely, I don't know how to do it right, sorry.
Suggested solution(s)
Either:
isInitialValid
?initialErrors
for this since I don't really know if what I am doing is correct or will be supported in the future. For example, iferrors
get checked more strictly, my trick of setting field errors to''
would stop working.Additional context
Your environment
Thanks
The text was updated successfully, but these errors were encountered: