bug: type="number" is not repected to v-model. String instead of number despite ref<number>
See original GitHub issuePrerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
- Nightly
Current Behavior
The string is returned to the model instead of the number.
Expected Behavior
The nnumber is returned to the model if type=“number”.
Steps to Reproduce
<template>
<ion-input type="number" v-model="itemQty" inputmode="numeric"></ion-input>
</template>
<script lang="ts">
export default defineComponent({
setup() {
const qty = ref<number>(1);
watch(qty, (value) => {
console.log(typeof value)
})
return {
qty
}
}
})
</script>
Code Reproduction URL
No response
Ionic Info
Ionic:
Ionic CLI : 6.18.1 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/vue 6.1.0
Capacitor:
Capacitor CLI : 3.4.0 @capacitor/android : 3.4.0 @capacitor/core : 3.4.3 @capacitor/ios : 3.4.0
Utility:
cordova-res : 0.15.4 native-run : 1.5.0
System:
NodeJS : v14.17.4 (/usr/local/bin/node) npm : 8.7.0 OS : macOS Monterey
Additional Information
I have found similar issues on Github but all of them related to Angular and not Vue, also they are 3-4 years old. The current workaround will be to use watchers and parseFloat the value, however i do not see it is a great workaround as the model updated twice, and the types also not respected so the result could be unexpected
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Sure I will create it.
Thank you On Apr 25, 2022, 4:10 PM -0400, Liam DeBeasi @.***>, wrote:
Thanks for the issue! This issue is being closed due to the lack of a code reproduction. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.