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

option to close on blur #233

Open
jstaerk opened this issue Sep 16, 2022 · 1 comment
Open

option to close on blur #233

jstaerk opened this issue Sep 16, 2022 · 1 comment

Comments

@jstaerk
Copy link

jstaerk commented Sep 16, 2022

  • vue-autosuggest version: 2.2.0
  • node version: 16.13.2
  • npm (or yarn) version: 8.5.2

Relevant code or config
My workaround:

    blur() {
      this.suggestionHasFocus=false;
    },
    focus() {
      this.suggestionHasFocus=true;
    },
    shouldRenderSuggestions (size, loading) {
      return size >= 0 && !loading && this.suggestionHasFocus;
    },

What you did:

typed something, left the input using e.g. the <TAB> key

What happened:

It closes the suggestion box only if I apply my workaround

Problem description:

Is there a option I miss or a particular reason why the suggestions are only closed when one clicks somewhere outside and not as well when the focus changes to another element?

Suggested solution:

my code

@bryan-gilbert
Copy link

I tried the above but then found that any mouse click on one of the options would close the dropdown but NOT select the option clicked. I took away the @blur property and the click on option worked again but then TAB away was broken again. I think this workaround helps.

        @focus="autoSuggestHasFocus = true"
        @keydown.tab="autoSuggestHasFocus = false"

with your suggested shouldRenderSuggestions()

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