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

"onUpdate" being called on every event on the page. #127

Open
ariademur opened this issue Mar 10, 2021 · 2 comments
Open

"onUpdate" being called on every event on the page. #127

ariademur opened this issue Mar 10, 2021 · 2 comments
Labels
good first issue Good for newcomers js Only applies to the autocomplete-js package
Projects

Comments

@ariademur
Copy link

Hello,

Using vanilla JS, I noticed that "onUpdate" is being called on any event on the page, not only when the results list is updated, as the documentation states.

Here's a Codepen example forked from "Simple autocomplete - @trevoreyre/autocomplete-js"
https://codepen.io/ariademur/pen/wvoQErz

Even if clicking around the page, no relation to the autocomplete, the "onUpdate" is called.

If this is intentional, is there any other way to get the functionality specified in the documentation, a function that is executed when the results list is updated?

Thanks in advance.

@trevoreyre
Copy link
Owner

I think that's happening because of the document click listener, which always calls the function to close the results list, even if it's already closed.

https://github.com/trevoreyre/autocomplete/blob/master/packages/autocomplete-js/Autocomplete.js#L194-L199

I think a fairly easy solution would be to just add a check in that function to see if the results list is already open, and only close it if it is.

@trevoreyre trevoreyre added good first issue Good for newcomers js Only applies to the autocomplete-js package labels Mar 11, 2021
@trevoreyre trevoreyre added this to To do in Current via automation Mar 11, 2021
@ariademur
Copy link
Author

Thanks!

For my purposes I ended up using a custom modified version of your script, but I will follow the project closely and looking forward to updates, I think it's one for the best autocomplete systems currently available, good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers js Only applies to the autocomplete-js package
Projects
Current
  
To do
Development

No branches or pull requests

2 participants