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
Slots inside ValidationProviders: validation inside slot not working correctly in 'eager' mode #2185
Comments
I've found a weird work-around that might also point in the right direction for a real solution. If I wrap the <template v-slot:default="props">
<input .../>
</template> Adapted example: |
That's a very good catch, I spent a couple of hours figuring what was the issue. The problem wasn't actually the growing list of listeners (now fixed) as they are still were being added as per the The problem was in the This is fixed by not syncing the value in the Thanks for reporting this! |
Cheers, thanks for the fix and the explanation! BTW great work on this plugin! |
@rvdrijst I do releases on a weekly basis, so there should be one coming up in the next couple of days. |
This was reverted because it introduces more bugs, I will try to investigate the issue again. |
Fixed by 07fa140 |
…garetm/vee-validate * upstream/v2: (689 commits) fix: update v3 links and repo links closes logaretm#2467 chore: add v3 docs link docs: add note for read me Added missing changes flag in FieldFlags definition (logaretm#2218) docs: uneeded document about escaping regex docs: fix the regex example chore: bump to 2.2.15 revert: logaretm#2185 closes logaretm#2209 chore: bump to 2.2.14 chore: upgrade dependencies fix: mark vee-validate handlers so they get deduped Revert "fix: don't sync the value in an event handler closes logaretm#2185" chore: rm .DS_Store test: fix failing tests due to punctation test: fix failing tests Remove periods at end of validation messages (logaretm#2195) alpha_helper.js: regex for persian characters has been added (logaretm#2190) fix: don't sync the value in an event handler closes logaretm#2185 fix: cleanup events before adding new ones Update displaying-errors.md (logaretm#2186) ...
Versions
Describe the bug
When using slots inside
ValidationProvider
, the inputs are recognized but event handlers are not bound correctly, leading to unexpected results.This seems the result of a bug that shows itself in eager mode, but is also present in other modes, as explained below.
To reproduce
I've prepared a minimal example here:
https://codesandbox.io/embed/veevalidate-slotted-input-problem-example-z0786
There are two fields here: one inside the slot in the same file as the
ValidationProvider
(default slot content). The second has the slot filled in a parent componentExampleForm
. The second field does not validate correctly.Steps to reproduce the behavior:
required
validation will trigger (expected)required
validation will trigger (expected)Expected behavior
In the second field, I expect the validation to work the same as in the first field.
Additional context
I've done a bit of debugging and it seems to be that
addListeners
is called quite a few times after every character that is typed. There, theonValidate
listener is added on the input throughaddVNodeListener
which eventually callsmergeVNodeListeners
onnode.data.on
. In the first field, these listeners are nice and clean (only 1 or 2 oninput
andblur
), but on the second field, they accummulate quite quickly (hundreds of event handlers per eventtype if you type a few characters) I suspect this is where something goes wrong, but I don't have enough insight into how this is supposed to work to know what exactly is happening here. Hopefully this is a helpful pointer.Note that this rapidly growing event handler list is also present in 'normal' mode, but somehow it doesn't interfere with the actual validation.
To see what happens, put a breakpoint in the code at
mergeVNodeListeners
and type a few characters in each field. Stepping through the calls tomergeVNodeListeners
you will see thatobj
grows very quickly for the second field (although the first few calls seem alright, suddenly there is an 'old' version that remembers listeners). The first fields stays nice and clean.The text was updated successfully, but these errors were encountered: