Skip to content
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 value is not updated with :value #2396

Closed
2ik opened this issue Oct 3, 2019 · 2 comments
Closed

Field value is not updated with :value #2396

2ik opened this issue Oct 3, 2019 · 2 comments
Labels
🐛 bug Unintended behavior

Comments

@2ik
Copy link

2ik commented Oct 3, 2019

Versions

  • vee-validate: 3.0.8
  • vue: 2.6.10

Describe the bug
if to use validation, v-model does not change. I understand that vee-validate is looking at v-model, but how can I get around this error in this case?

To reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/embed/vuex-form-2g8id
  2. To write on field "Name (Vee-validate)"

Expected behavior
the field must change

Demo link
https://codesandbox.io/embed/vuex-form-2g8id

Additional context
Sorry for my english ;)

@logaretm
Copy link
Owner

logaretm commented Oct 5, 2019

Looks like this is caused by #2355 The problem happens because when you press on a key, the component re-renders and when that happens the binding hasn't been updated yet. causing the component to revert.

I will see what I can do.

@logaretm logaretm added the 🐛 bug Unintended behavior label Oct 5, 2019
@logaretm
Copy link
Owner

logaretm commented Oct 5, 2019

Okay after investigation, the issue isn't really caused by vee-validate and cannot be fixed within it.

The workaround is to bind the :value with a live reference to the actual value, otherwise vee-validate won't be able to detect the value properly.

This can be done by copying the user object from the store to the local state whenever it changes:

https://codesandbox.io/s/vuex-form-uccc0

This can also be done by using computed setters, however, I assume you don't want to commit state to the store unless they pass validation.

@logaretm logaretm closed this as completed Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants