-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Field type=checkbox
does not work properly with v-model
#3105
Comments
Thank you for the detailed demo, it helped a lot. There was indeed a bug with the As a workaround you could wrap it in a https://codesandbox.io/s/vee-validate-checkbox-bug-forked-od4ud?file=/src/App.vue I have fixed the issue and a release should be out shortly. |
👍 Thanks! I worked around the issue for now (I didn't actually need to use validation for that field, but I was using the component everywhere for consistency), but it is nice to know I can revert my work around when the next update hits. |
This issue appears to still be present in the latest version (4.2.4), albeit in changed form. Now the value is simply set to undefined and left at that. This behavior first appears in 4.1.4 (Wrapping a checkbox Field in another component (inside a Form) results in an issue very similar to this issue. I still need to investigate a bit more and write up a reproduction, but while working on that I revisited this issue and found out that it hadn't been fixed after all.) |
So now there are Feel free to build a reproduction and I will take another look, cheers! |
Hi, is this documented anywhere? |
This bug is also reproduced with useField. In your custom checkbox example. Demo: https://stackblitz.com/edit/vee-validate-v4-custom-checkboxes-9r3jcv?file=src%2FApp.vue |
Thanks bro, it worked for me |
Versions
Describe the bug
When using
<Field type="checkbox" v-model="checked"/>
the value ofchecked
will often be wrong. If it starts false, checking the box will set it to"on"
(expected:true
), unchecking will leave the value set to"on"
! (expected:false
) From this point on unchecking the box will set the value to"on"
(expected:false
) and checking it will set the value to""
(expected:true
).In the sandbox the behavior is a little different, there the
v-model
gets "stuck" to"on"
no matter how many times you check or uncheck the box.Replacing the
Field
tag with a simpleinput
works exactly as expected.To reproduce
Field
withtype="checkbox"
and av-model
.v-model
as you check and uncheck the box.Expected behavior
The checkbox should set the
v-model
to the proper boolean values instead of... whatever you want to call its current behavior.Demo link
Desktop:
The text was updated successfully, but these errors were encountered: