vuejs-tips / vue-the-mask

Tiny (<2k gzipped) and dependency free mask input for Vue.js
https://vuejs-tips.github.io/vue-the-mask/
1.74k stars 213 forks source link

Input @blur.native not reset the value properly #110

Open Bigdragon13th opened 5 years ago

Bigdragon13th commented 5 years ago

Scenario: I need a number input that will reset its value back to min value if the value in the field is lower than min value only after it's blur.

Current Behavior: Given this snippet:

<template>
  <div>
    <TheMask
      :mask="['####']"
      v-model="count"
      @blur.native="resetCount"
    />
    <div>{{ count }}</div>
  </div>
</template>

<script>
import { TheMask } from 'vue-the-mask';

export default {
  components: {
    TheMask,
  },

  data() {
    return {
      count: 1,
      minCount: 1,
    };
  },

  methods: {
    resetCount() {
      if (this.count < this.minCount) {
        this.count = this.minCount;
      }
    },
  },
};
</script>

The count in mask input failed to update if:

I tried debugging and found that lastValue in the component not updated properly when the value update via @blur from parent, this might be the cause of the issue.

kosmeln commented 4 years ago

I've bumped into exact same issue.

@Bigdragon13th, did you manage to fix it?

Bigdragon13th commented 4 years ago

@kosmeln I can't remember this anymore, it's too long ago, lol. I think I created my own input for this at that time.