v-mask icon indicating copy to clipboard operation
v-mask copied to clipboard

Error using v-mask in custom vuetify component

Open alanscordoba opened this issue 5 years ago • 4 comments

V-mask does not work in a vuetify v-text-field component. Apparently it generates some conflict with v-model

By applying in form this. $Refs.form.resetValidation () and this. $refs.form.reset () v-model variable is not reset

Versions: "v-mask": "^2.2.3" "vue": "^2.6.12" "vuetify": "^2.3.10"

<template>
    <v-text-field
        v-model="value" 
        v-mask="mask"/>  
</template>

<script>
    import createNumberMask from 'text-mask-addons/dist/createNumberMask';

    const number = createNumberMask({
        prefix: '',
        includeThousandsSeparator: true,
        thousandsSeparatorSymbol: '.',
    });

    data: () => ({
           mask = "number"
        }),

</script>

alanscordoba avatar Sep 30 '20 15:09 alanscordoba

any news regarding this query?

alanscordoba avatar Nov 04 '20 13:11 alanscordoba

From what I gathered, there is a race condition when the input is updated, depending on which fires first, either it will be reset or it won't.. I have the same issue on blur, basically setting a value on input blur will result 50% of the time on the value you want to set, the rest of the time the input is reupdated right away with the previous value

As you can see input is fired sometimes after a blur and that's when the value stays the same image

When it doesn't image

Needs some more digging

Tofandel avatar Feb 16 '21 14:02 Tofandel

Ok so basically the problem is in how the updated event fires in vue even though the value of the underlying element is not yet updated, I think just running the update on next tick should fix the issue

Tofandel avatar Feb 16 '21 14:02 Tofandel

Ok, básicamente, el problema está en cómo se activa el evento actualizado en vue, aunque el valor del elemento subyacente aún no se ha actualizado, creo que solo ejecutar la actualización en el siguiente tick debería solucionar el problema

Hi, thank you for you answer. Could you comment on how to implement the proposed solution?

alanscordoba avatar Oct 26 '21 10:10 alanscordoba