Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-model overrides the value of a number with trailing zeros #7003

Closed
baiwusanyu-c opened this issue Nov 1, 2022 · 3 comments · Fixed by #7004
Closed

v-model overrides the value of a number with trailing zeros #7003

baiwusanyu-c opened this issue Nov 1, 2022 · 3 comments · Fixed by #7004
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: v-model

Comments

@baiwusanyu-c
Copy link
Member

baiwusanyu-c commented Nov 1, 2022

Vue version

3.2.41

Link to minimal reproduction

https://sfc.vuejs.org/#eNp9kd1ugzAMhV/Fyg2bVEjJJYJKe4/ctNRsVM2PnMA0Id59DrQT66ZeOcc++Rw7k3jzvhgHFJWoQ0u9jxAwDv6gbW+8owgTEHYwQ0fOQMbWTFttW2dDBDuYEppkeCmL/V69bgrqoVDLlc9kFhGNvx4jsgKo/aG3fohlLVNjTiwSxty4M14bLVIjLSB+eWwyFiekDO53U4DlLdU0pTDPS+UOu9HVM7r6n/4Lr1a82uJr+TOJ2Il1Zbk5+uISnOWlTsmqb4WgRQVLJuV4lUlr8RGjD5WUoWvTV1xC4ehd8qmgwcbeYIHB5CdynwGJwVrsNgzJyREpJ7RnJKRnzAfrH27C8nCzmL8Bq8W0nQ==

Steps to reproduce

1.Delete the data of input1, from 1.002 to 1.00
2.Delete the data of input2, from 1.002 to 1.00

2022-11-01.20.52.52.mov

What is expected?

After step 1 is executed. The display value of input1 is 1.00.
After step 2 is executed, the display value of input1 and input2 are both 1.00

What is actually happening?

After step 1 is executed. input1 shows a value of 1.00, but when step 2 is executed, input1 shows a value of 1

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 6.41 GB / 15.74 GB
  Binaries:
    Node: 16.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (107.0.1418.26)
    Internet Explorer: 11.0.19041.1566

Any additional comments?

No response

baiwusanyu-c pushed a commit to baiwusanyu-c/bwsy-vue-core that referenced this issue Nov 1, 2022
baiwusanyu-c added a commit to baiwusanyu-c/bwsy-vue-core that referenced this issue Nov 1, 2022
@baiwusanyu-c
Copy link
Member Author

@sxzz hey bro, help me to determine if it is a bug, thank you 🙏

@posva posva changed the title v-model does not update correctly when the element is an input of type number v-model overrides the value of a number with trailing zeros Nov 4, 2022
@posva
Copy link
Member

posva commented Nov 4, 2022

This is a side effect of vue rendering again and setting the input value to the new value which have the trailing zeros stripped as it's a number.

I remember we discussed this kind of formatting requires handling with a string (so any trailing zero is kept) in userland but I think this could be improved too. At the time I think we didn't cast the v-model variable to a number unless the .number modifier was passed to v-model

@posva posva added scope: v-model 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels Nov 4, 2022
@baiwusanyu-c
Copy link
Member Author

This is a side effect of vue rendering again and setting the input value to the new value which have the trailing zeros stripped as it's a number.

I remember we discussed this kind of formatting requires handling with a string (so any trailing zero is kept) in userland but I think this could be improved too. At the time I think we didn't cast the v-model variable to a number unless the .number modifier was passed to v-model

Then can we add some judgment conditions to solve this problem, like the pr I put forward

@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. scope: v-model
Projects
None yet
2 participants