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

Use of validateAll(scope) breaks required rule on list of select inputs #923

Closed
ThomHurks opened this issue Oct 28, 2017 · 5 comments
Closed
Labels
🐛 bug Unintended behavior

Comments

@ThomHurks
Copy link
Contributor

ThomHurks commented Oct 28, 2017

Versions:

  • VueJs: 2.5.2
  • Vee-Validate: RC19 and master branch as of time of posting.

Description:

I have a dynamic list of select inputs with the required rule on them. These select inputs use a certain scope. Within that scope, I also have a custom component that is not bound using v-model since it renders an array, so after the data for that component changes I just call validateAll(scope) on $nextTick because otherwise the initial validation for that custom component doesn't work. This works fine, but strangely enough when using validateAll(scope) the required rule on the list of select inputs breaks. This puts me in the awkward position that whether I add or remove validateAll, some validation is always broken. I may refactor all this code in the future, but in the meantime I don't think calling validateAll(scope) should break anything.

Steps To Reproduce:

https://jsfiddle.net/kt2r8r60/5/

@logaretm
Copy link
Owner

You are correct, calling validateAll shouldn't break or produce different results than the initial validation, I will take a look and report back. Probably the value resolution has issues with select inputs.

@ThomHurks
Copy link
Contributor Author

Thanks! :)

@logaretm logaretm added the 🐛 bug Unintended behavior label Oct 28, 2017
@logaretm
Copy link
Owner

I found the problem, for starters it only occurs with Vue 2.4.3 and above, I think because of this change vuejs/vue#6193

This is similar to #804 but not easily as fixable, because when you don't call validateAll the initial value is retrieved by the vnode which only happens initially. When you call validateAll the predefined getters are now the source of the value which for select elements aren't ready yet and so it receives an empty value.

Fixing it would require a different way of retrieving v-model bound values, preferably via the vnode data itself since it is isolated from all DOM cycles and the pain that comes with tracking them.

@logaretm
Copy link
Owner

logaretm commented May 8, 2019

This has been fixed finally in the v3 branch, as the directive has been re-written.

@logaretm logaretm closed this as completed May 8, 2019
@ThomHurks
Copy link
Contributor Author

Thanks @logaretm!

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