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

"Aggressive" mode incorrectly behaves like "lazy" on slots for first validation #2229

Closed
bbugh opened this issue Aug 24, 2019 · 3 comments
Closed
Labels
🐛 bug Unintended behavior

Comments

@bbugh
Copy link

bbugh commented Aug 24, 2019

This may be related to #2185 but the behavior is different so I'm making a new bug.

Versions

  • vee-validate: 3.0.1
  • vue: 2.6.10

Describe the bug

When ValidationProvider is the top level of a child component, aggressive mode behaves like lazy until the first blur, whether it's set via mode or defaulting.

Given a component template like this:

<template>
  <ValidationProvider v-slot="{ touched, errors }" :name="label" :rules="rules">
    <slot />
  </ValidationProvider>
</template>

Using the component with the slot works and validates, but only after the first blur.

<!-- this does not work "aggressively", and only validates after first blur -->
<form-row label="Name" rules="required">
  <input id="nameInput" v-model.trim="name" class="form-control">
</form-row>

To reproduce

Steps to reproduce the behavior:

  1. Make a component that has the ValidationProvider as the top element and a slot
  2. Use the component, passing in a default slot
  3. Observe that the default mode behaves like lazy for the first validation only

Expected behavior

Aggressive mode should always validate in real time, not just after first blur.

Desktop (please complete the following information):

  • OS: Mac OS
  • Browser: Firefox
  • Version 68.0.2
@logaretm logaretm added the 🐛 bug Unintended behavior label Aug 24, 2019
@logaretm
Copy link
Owner

Interesting, I guess there is a general issue with slots inside the slot scope. Will investigate and report back.

@logaretm
Copy link
Owner

OK, Good news. I found the issue and managed to fix it. It was due to vee-validate not being able to detect the correct input type. So it falls back to using change event for validation.

This was due to your input not having a type="text" attribute, I have added a small case for it.

While this looks close to #2229 it doesn't seem to fix it.

@MinaMalak-cmd
Copy link

MinaMalak-cmd commented Jun 19, 2022

Although I used the type attribute but a similar issue still existed here is my code

`<validation-provider 
             rules="phone" v-slot="{ errors,dirty,touched,changed }" mode="aggressive"
          >
                        <input class="" :class="returnPhoneErrorClass()" type="text" v-model="phone_number" 
                          :placeholder="$t('generalTab.phoneNumber')" :disabled="!editInfo"
                        @input="check(dirty,touched,changed)"
                        >
                       
          </validation-provider>`

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

3 participants