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

Unexpected behavior on keyup #56

Open
jprivillaso opened this issue Apr 5, 2018 · 6 comments
Open

Unexpected behavior on keyup #56

jprivillaso opened this issue Apr 5, 2018 · 6 comments

Comments

@jprivillaso
Copy link

Hi,

I'm not sure if i'm making some mistake but I'm following the demo code.
The problem that I'm having is that the method getLabel gets called twice the first time, one time with undefined parameter and the second time it is called with the correct word that I just typed.

The problem in consequence is that for example, I type the word: abcd, then the field is cleared and only bcd is applied.

The difference in my code is that my template is not an object but a string, as follows:

<template>
  <div>
    <span>{{ item }}</span>
  </div>
</template>

<script>
export default {
  props: {
    item: { required: true }
  }
};
</script>

and my getLabel method is as follows:

getLabel(item) {

  if (item) {
    return item;
  }
  return '';

}

One important thing is that I don't want the field to be initialized. The demo example initializes the field with some object, then you have to delete the current word and then everything works as expected.

To reproduce the error leave the item as an empty object or an empty string.

export default {
  name: 'demo',
  components: {'v-autocomplete': Autocomplete},
  data () {
    return {
      itemsApi: [],
      item: {},
      items: [],
      tpl: tpl
    }
  }
}

Thanks

@maganius
Copy link

I have same issue, the first time when the input is empty, the first keyword don't appears.

@maganius
Copy link

@paliari any idea to avoid this behavior? is very important thanks you!

@blackgearit
Copy link

for me solved with item = null as initial value (null, not {})
#44

@oksidisko
Copy link

Thanks @blackgearit for the solution.

If this is not a bug but feature, I think it better should be documented, because this behavior is really confusing.

@ghost
Copy link

ghost commented May 21, 2018

Same issue. It is fixed by the proposed sultion, but I had to make use of the focus and change events to prevent the bug from happening when providing a selected item to the autocomplete input.

This is hardly a feature, but a bug.

@maganius
Copy link

@blackgearit item cant be reactive if its initialized null in vuejs 2

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

4 participants