Skip to content
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

Select is not updating when v-model was changed #923

Closed
tikagnus opened this issue Aug 6, 2019 · 2 comments
Closed

Select is not updating when v-model was changed #923

tikagnus opened this issue Aug 6, 2019 · 2 comments

Comments

@tikagnus
Copy link

tikagnus commented Aug 6, 2019

Describe the bug
Select is not updated when the v-model variable was changed, at least when we have a custom reduce and object type options.

To Reproduce
Steps to reproduce the behavior:

  1. Declare a variable entity in data()
  2. Use entity as v-model or :value
  3. Update entity in a method of current component
  4. Select was not updated

Expected behavior
Select should be updated when we change the entity value.

Screenshots
image

Desktop (please complete the following information):

  • OS: MacOs Mojave
  • Browser Chrome
  • Version 75

Additional context

<template>
  <v-select
    :reduce="item => item.id"
    label="label"
    :options="entities"
    v-model="entity"
  >
  </v-select>
</template>

<script>
  export default {
    name: 'Dropdown',
    data () {
      return {
        entity: null,
        entities: []
      }
    },
    methods: {
      async handleSearch (search, loading) {
        loading(true)
        try {
          const res = await this.$http.get('persons', {
            params: {
              q: search
            }
          })
          const { data } = res
          this.items = data
        } catch (e) {
        }

        loading(false)
      },     
    },
    beforeMount () {
      this.entities = [
        {
          id: 1,
          label: 'a'
        }, {
          id: 2,
          label: 'b'
        },
      ]
      setTimeout(e => {
        console.log('entity value before change', this.entity)

        this.entity = 2
        console.log('entity value after change', this.entity)
      }, 2000)

    }
  }
</script>

This issues was not in 2.6 version.

As a temporary solution I added a watcher on the value tikagnus@360b0b4

@doits
Copy link
Contributor

doits commented Aug 7, 2019

Should be fixed by #914

@sagalbot
Copy link
Owner

Fixed by #914.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants