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

Focus on input with a window.scroll don't auto open suggestions #100

Closed
willjosefi opened this issue Feb 26, 2019 · 3 comments
Closed

Focus on input with a window.scroll don't auto open suggestions #100

willjosefi opened this issue Feb 26, 2019 · 3 comments

Comments

@willjosefi
Copy link

  • vue-autosuggest version: 1.8.1
  • node version: v8.11.3
  • npm (or yarn) version: 6.4.1

Relevant code or config

What you did:
Using @Focus with a window.scroll call.
The reason for scroll window, is because i need to put input on top of the page on mobile devices, to helps keyboard to not hide the input and suggestions

What happened:
Window is scrolled to top but the suggestion don't auto open. I need to click again on input to suggestion being showed.

I created codesandbox showing this happening:
https://codesandbox.io/s/o5947nqlp9
Just click on input, window will be scrolled to top, but suggestion will not be showed, you need to click again on input.

@darrenjennings
Copy link
Owner

There is some custom behavior in the latest beta which will help do whatever you need, but doesn't switching the @focus event to @click or @mouseup fix your issue? e.g. https://codesandbox.io/s/qqqzqryq4w

@willjosefi
Copy link
Author

hmm.. good idea on using @click, didn't think about that option, as i will use only for mobile devices this seems to work for me.

Thanks...

But, can you give me a quick explanation on why this happen?

@darrenjennings
Copy link
Owner

@willjosefi it looks like when you run your function with @Focus, window.scroll(0, findPos(input)); will fire before the click event and prevent it from firing. With @click window.scroll does not stop vue-autosuggest click event.

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