vue-numeric icon indicating copy to clipboard operation
vue-numeric copied to clipboard

New input displays formatted value if focused too quickly

Open mgasparel opened this issue 6 years ago • 0 comments

If you set the focus on a new vue-numeric input immediately after creating it, the input does not stay cleared, and will display the formatted value after a brief moment, as if it has lost focus.

I can see that in the mounted() event, we're updating the value, then updating it again 500ms later. I don't want to attempt to fix this without understanding what the purpose of this delay is:

      // In case of delayed props value.
      setTimeout(() => {
        this.process(this.valueNumber)
        this.amount = this.format(this.valueNumber)
      }, 500)

Expected Behavior

A new vue-numeric input, when focused immediately after being created, should remain focused and should remain cleared until the first blur event

Actual Behavior

If the new input is focused too quickly, the formatted value is displayed instead of remaining blank

Steps to Reproduce the Problem

  1. Create a new instance of vue-numeric
  2. Immediately set focus to the new input.
  3. Input correctly receives focus and contains no value
  4. Half a second later, the input sets it's value to $0.00 and retains focus

Specifications

  • Plugin Version: 2.3.0
  • Vue.js Version: 2.5.16
  • Browser: Chrome
  • OS: Windows 10

mgasparel avatar May 07 '18 02:05 mgasparel