QInput does not update when cleared
-
I am using the QInput to enter the user’s age which utilies a computed get/set property to communicate with the store.
This all works fine except for when the age is backspaced so the input is empty. Upon removing the last single digit, there is no event fired meaning that the store value is stuck at the value of that single digit until there is another input or the field is blurred.
I have also tried firing methods with the ‘input’, ‘change’ and ‘clear’ events, none of which fire upon the final backspace.
What can I do about this?
<template> <q-field > <q-input v-model="age" float-label="Age" type="number" /> </q-field> </template> <script> export default { computed: { age: { get () { return this.$store.getters['age'] }, set (newAge) { this.$store.commit('SET_AGE', newAge) } } } } </script>
-
This seems to have been a bug in the QInput with type=“number”
Thankfully this has been corrected in 1.0.0-beta.0
-
Is there a work around for this, i have the same problem
-
@Theo this is what I ended up implementing
methods: { input (newValue) { if (newValue !== '') { newValue = parseInt(newValue) } else { newValue = null } this.$emit('change', newValue) } }