pespantelis / vue-typeahead

:mag: Typeahead component for Vue.js
http://pespantelis.github.io/vue-typeahead
MIT License
517 stars 98 forks source link

Reset current selection when items are reset #52

Open yunyu opened 7 years ago

yunyu commented 7 years ago

I'm currently using this component in a pseudo-form that allows the user to submit the form if the input field receives an enter (not the autocomplete popup). I'm doing this by implementing a processEnter method based off of the onHit method:

    processEnter() {
      if (this.current !== -1) {
        this.onHit(this.items[this.current]);
      } else {
        this.$emit('pressed:enter');
      }
    }

Currently, onHit will be called instead of emitting the enter press event after a reset(). This commit fixes that behavior.