Skip to content

New input displays formatted value if focused too quickly #68

Open
@mgasparel

Description

@mgasparel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions