ankurk91 / vue-jquery-mask

Vue.js component for jQuery mask plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When I use clearIfNotMatch and the mask not match, v-model does not update

luisenriquegomesportugal opened this issue · comments

You can check in this example https://jsfiddle.net/ankurk91/d92xgzhL/, just add the clearIfNotMatch: true, in the options, and put a wrong value on input.

I think the right thing would be when the value does not match the mask, the v-model should be blank, equal to the input value.

I looked at the source code, and realized that have to modify on the component.vue:

onBlur(event) {
    this.$emit('blur', this.value)
}

to:

onBlur(event) {
    this.$nextTick(() => {
        let toEmit = this.raw ? jQuery(this.$el).cleanVal() : event.target.value;
        this.$emit('input', toEmit);
        this.$emit('blur', this.value)
    });
}

Once the onBlur event is triggered it should update the value of the v-model because the field can clear because of the wrong value for the mask.

If possible, I'd like you to take a look, I'm needing too much of this component.

Thank you very much in advance.

This should be fixed with 1.0.3

https://jsfiddle.net/v84bgaeu/2/

Oh, nice. Thank you so much.