darrenjennings / vue-autosuggest

🔍 Vue autosuggest component.
https://darrenjennings.github.io/vue-autosuggest
MIT License
621 stars 91 forks source link

Focus on the first item in the list #77

Closed lordenas closed 6 years ago

lordenas commented 6 years ago

Hi. Thank You for Your work. Is it possible to make the first item of the list always active. For example: full name "Lynne Graham". I write " Lean."... press enter and select the first.

ice_video_20181106-160812

darrenjennings commented 6 years ago

You can do it by accessing the internal method setCurrentIndex via refs:

https://mq9869lz2x.codesandbox.io/

e.g.

this.$refs.autosuggest.setCurrentIndex(0)

disclaimer: refs are more of an escape hatch so it will work for now but I plan on making this part of of the api in the future where you can hook into the event system with a "data reducer". So the method setCurrentIndex is subject to change in future releases. Should be good for now 🙃

lordenas commented 6 years ago

Thank you!

jetlej commented 4 years ago

This doesn't seem to work anymore. Is there an updated version?

jetlej commented 4 years ago

Or rather, could you make the source code visible on your codesandbox link? (https://mq9869lz2x.codesandbox.io/)