darrenjennings / vue-autosuggest

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

Question - How to force suggestion list to render on input focus #171

Closed imt-telliott closed 4 years ago

imt-telliott commented 4 years ago

If this isn't the correct place to ask this type of question, please let me know.

I would like to know the suggested way of forcing the suggestion list to render when the input receives focus via tabbing. Right now, it appears that functionality only occurs when the input is actually clicked.

Thanks!

darrenjennings commented 4 years ago

@imt-telliott you can use the should-render-suggestion to create a focus state.

Example: https://codesandbox.io/s/vueautosuggest-171-22l6b

e.g.

 <vue-autosuggest
  ...
  @focus="isFocused = true"
  @blur="isFocused = false"
  :should-render-suggestions="(size, loading) => (size >= 0 && !loading) || isFocused"
>

I like this behavior!

imt-telliott commented 4 years ago

Thanks so much for the quick reply, I was looking at the source and it never occurred to me to override this and instead I went the "hacky" way and updated loading to meet my needs.

This is much better.