Skip to content

bug: type="number" is not repected to v-model. String instead of number despite ref<number>  #25186

@z0lo13

Description

@z0lo13

Prerequisites

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions