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

hotfix for select(index) #369

Open maksimbykov opened 2 years ago

maksimbykov commented 2 years ago

Fix #356

maksimbykov commented 2 years ago

@TarekRaafat please review this when you'll have time, thanks❤️

AndrewElans commented 1 year ago

Any news on this bug?

AndrewElans commented 1 year ago

I guess the reason why this TypeError: Cannot set properties of undefined (setting 'event') is fired is because select(index) is called when function init (ctx) is not yet complete.

I have fixed in my case by placing select(index) in the results event which seems to run after init is finished.

Before I tried to call select(index) on window.load and other events but in vain. Also in init event the same error was generated. I guess that even if the init event is fired, the init promise may still be not returned.