No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    QInput does not update when cleared

    Framework
    computed q-input v-model
    2
    4
    984
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jezzta667
      Jezzta667 last edited by

      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>
      1 Reply Last reply Reply Quote 0
      • Jezzta667
        Jezzta667 last edited by

        This seems to have been a bug in the QInput with type=“number”

        Thankfully this has been corrected in 1.0.0-beta.0

        1 Reply Last reply Reply Quote 0
        • T
          Theo last edited by

          Is there a work around for this, i have the same problem

          Jezzta667 1 Reply Last reply Reply Quote 0
          • Jezzta667
            Jezzta667 @Theo last edited by Jezzta667

            @Theo this is what I ended up implementing

            methods: {
                input (newValue) {
            
                  if (newValue !== '') {
                    newValue = parseInt(newValue)
                  } else {
                    newValue = null
                  }
            
                  this.$emit('change', newValue)
                }
              }
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post