-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Remove attribute when v-model.number is empty #5731
Comments
I guess current behavior is the expected one. |
I will find a work around, thank you :) 👍 |
As you saw in #4742, it's expected behavior. the reason is to allow the user to know when no value is provided in the input. Otherwise, a 0 could be entered by the user and also an empty input |
@posva After further understanding Vue's reactivity, returning null would definitely be the better option rather then returning a string |
What problem does this feature solve?
Solves a design pattern issue, that is of course expected from an MVM flow including v-model.number producing a string when empty.
When i enter a number and then delete the text from input, it turns into a string in the reactive data object.
This is certainly a major usability and casting issue, and i don't see the purpose of keeping an empty string attribute on the model. It should get spliced out of the model when its empty - just as you create new attributes on the text entry, it should be vice versa.
This is certainly a design pattern issue that should be resolved, not needing to be implemented on the application level each time, it's a small fix that will add a lot to VueJS2, and i'm sure many others will agree with me on this!
What does the proposed API look like?
Currently when input is empty
v-model.number="model.number"
model = {
number: ""
}
What it should do when input is empty
v-model.number="model.number"
model = {
}
The text was updated successfully, but these errors were encountered: