Input [v-model & type=number] is truncated when (unrelated) DOM update happens. #4392

Closed
patrickb1991 opened this Issue Dec 5, 2016 · 4 comments

Projects

None yet

3 participants

@patrickb1991

Vue.js version

v2.1.3

Reproduction Link

http://jsfiddle.net/1y2nk1L9/5/

Steps to reproduce

Enter a number with some zeros after the comma into a type="number" input field, while Vue performs some page rendering in the background with (unrelated) variables of the same component.

What is Expected?

Entering a number like 1.00001 works without issues.

What is actually happening?

Every time Vue triggers a DOM change all v-model input fields are "re-rendered" ("0.000" -> "0") which makes it impossible to enter decimal numbers that contain zeros in busy components. While this sounds like a minor issue it is a huge problem, since the entered number could be completely wrong. Imagine entering 1.00345, but the input is silently changed to 1345. This has already led to some serious trouble in our (financial) Vue application.

@defcc defcc added 2.x bug labels Dec 6, 2016
@defcc
Member
defcc commented Dec 6, 2016

When input gets focused and the user is inputing something, the input value property should not be updated. I'll make a patch.

@defcc
Member
defcc commented Dec 6, 2016

The same problem with trim modifier, I'll try to fix it together.

@yyx990803 yyx990803 closed this in 8a7b02a Dec 8, 2016
@yyx990803 yyx990803 added a commit that referenced this issue Dec 8, 2016
@yyx990803 yyx990803 proper fix for #4392 (via #4402) 0163a6f
@yyx990803
Collaborator

Hey @patrickb1991 , sorry for the potential problems this have caused in your app. Before a new release is out, you can build Vue from the dev branch locally to see if it fixes your issue.

@patrickb1991

No problem @yyx990803! Thanks for your great work and the fast fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment