Skip to content

How to open the dropdown from the browser console? #1620

Answered by sagalbot
Krzysiaczek asked this question in Q&A
Discussion options

You must be logged in to vote

The dropdown state is controlled by the focus of the input[type=search] within the component. When that element is focused, the dropdown is open. On blur, it closes.

document.querySelector(".vs__search").focus()

That should do the trick for you in tests, but won't work in the console. When hit return to call the command in the console, focus is returned to the console, which means the dropdown will never open.

setTimeout(() => document.querySelector(".vs__search").focus(), 5000);

If you run the above, then quickly click anywhere in the browser window, you'll see the dropdown open.

Best of luck!

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Krzysiaczek
Comment options

@sagalbot
Comment options

Answer selected by Krzysiaczek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants