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

API Call to select an resultItem is not working #356

Open
Erseni opened this issue Jul 8, 2022 · 3 comments · May be fixed by #369
Open

API Call to select an resultItem is not working #356

Erseni opened this issue Jul 8, 2022 · 3 comments · May be fixed by #369
Labels
bug Something isn't working

Comments

@Erseni
Copy link

Erseni commented Jul 8, 2022

The following api call
autoCompleteJS.select(0);
is throwing a TypeError
Uncaught TypeError: Cannot set properties of undefined (setting 'event')

To reproduce just enter the api call at the end of the official codepen example:
https://codepen.io/tarekraafat/pen/rQopdW

@Erseni Erseni added the bug Something isn't working label Jul 8, 2022
@maksimbykov
Copy link

The following api call autoCompleteJS.select(0); is throwing a TypeError Uncaught TypeError: Cannot set properties of undefined (setting 'event')

To reproduce just enter the api call at the end of the official codepen example: https://codepen.io/tarekraafat/pen/rQopdW

Got the same Issue

@maksimbykov maksimbykov linked a pull request Aug 31, 2022 that will close this issue
@maksimbykov
Copy link

added PR #369

@AndrewElans
Copy link

AndrewElans commented Apr 29, 2023

If you place autoCompleteJS.select(0) in the results event, it fires without error.
autoCompleteJS.input.addEventListener("results", function (event) { console.log(event.detail); autoCompleteJS.select(0) });

Type something and item with index 0 is automatically selected.

I guess if autoCompleteJS.select(0) is run before, the Init event may not be finished yet which throws error. Explained also in in PR #369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants