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

How can I use the tab key to select a suggestion? #172

Closed
canvasandcode opened this issue Feb 24, 2020 · 6 comments
Closed

How can I use the tab key to select a suggestion? #172

canvasandcode opened this issue Feb 24, 2020 · 6 comments

Comments

@canvasandcode
Copy link

Hi,

I've been asked to allow users to use the tab key to select an autosuggestion. Currently, it works fine using the up and down arrow and using the enter key. But for some reason, I have to have the exact same functionality with the tab key.

My Vue file looks like this:

https://codesandbox.io/s/vueautosuggest-api-fetching-k7pvw

I would greatly appreciate your help and advice on this.

Thanks

@darrenjennings
Copy link
Owner

Looks like that example is missing vue-bootstrap dependency and the restaurant data file isn't there. Either way, this might help you get what you need:

https://codesandbox.io/s/vueautosuggest-172-q96jp

The idea being that you need your own "loading" state variable to tell vue-autosuggest when to render and fire off the onSelected event through a ref (but then clearing the hasTabbed in the click and focus events so that it behaves normally):

tabHandler(e) {
  this.$refs.autosuggest.listeners.selected(true)
  this.hasTabbed = true
}

@canvasandcode
Copy link
Author

canvasandcode commented Feb 24, 2020 via email

@darrenjennings
Copy link
Owner

the ref you pasted is called "autocomplete" so you'd need to reference that e.g. this.$refs.autocomplete.listeners.selected

@darrenjennings
Copy link
Owner

@canvasandcode did this help?

@canvasandcode
Copy link
Author

Sorry for the late response, the project was paused due to everything happening :) Thanks for your help!

@darrenjennings
Copy link
Owner

sorry to hear @canvasandcode hope you are well and safe.

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

2 participants