TarekRaafat / autoComplete.js

Simple autocomplete pure vanilla Javascript library.
https://tarekraafat.github.io/autoComplete.js
Apache License 2.0
3.93k stars 236 forks source link

Keep resultsList open on "selection" #236

Closed sniepoort closed 3 years ago

sniepoort commented 3 years ago

I can't find any mention in the docs on how to keep the resultsList open after making a selection. I assume that the resultsList default behaviour is to close on blur, which happens when you make a selection. However, adding an input.focus() in the selection event doesn't trigger it to reopen.

TarekRaafat commented 3 years ago

Hello @sniepoort,

Try the below configuration and let me know how it goes.

events: {
    input: {
        close: () => {
            autoCompleteJS.open();
        }
    }
},
sniepoort commented 3 years ago

@TarekRaafat Thanks for following up :) This works of course, but also means I can never close the resultList haha. I.e. it should still close on input blur, etc. I only want it to stay open on "selection" events, i.e. on enter or click on result. But maybe I have to take care of that through traditional JS instead?