-
Notifications
You must be signed in to change notification settings - Fork 332
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
Ability to filter suggestions before display #251
Comments
The second argument to the |
@Haroenv I'm not using an Algolia source. Would that be called even if suggestions were cached, though? |
Autocomplete doesn't have a cache, can you give the code you're using? |
Using jQuery JS for This looks like caching to me: https://github.com/algolia/autocomplete.js/blob/v0.31.0/dist/autocomplete.jquery.js#L2537 |
I didn't know that, I've only worked on other parts of the code base. Do you have a suggestion on how to fix it, maybe allow disabling of the cache? The best way would be that you allow filtering (maybe with a callback argument) to your own source, that way you can control filtering without a change in cache etc. |
I think filtering is the best approach as disabling cache requires more work for the developers (disable cache + handle filtering of results). A new option called It could be implemented inside the
Thoughts? |
Is there a reason you prefer this in the library over putting it in userspace (like the Algolia one does) |
I'm not sure how to implement it in userspace to bypass the caching since the Suggestions are welcome. |
I have this implemented locally. Would you be open to a PR (with tests, docs, etc.)? |
Would be interesting to see what you came up with yes 😊 I've taken a deeper look and noticed that the cache in autocomplete.js is only for a single previous query. In the case of filtering frontend, it should be fairly safe to simply disabling the cache, but I think it will make more sense when I see what your implementation is |
It turns out that filtering is not sufficient. There is an edge case that it doesn't handle:
Disabling caching is a better approach. It still leaves caching possible in userspace. I will work on a MR. |
Thanks, that's what I thought would be more appropriate too! a PR would be appreciated 🚀 |
Closing. There is another solution that doesn't require lib changes: passing the filter function to the dataset on initialization. |
Do you want to request a feature or report a bug?
Feature.
What is the current behavior?
What is the expected behavior?
Use Case
I am using the autocomplete input to allow the user to add "tags" to a list. If the user adds a tag, it needs to be hidden from the dropdown subsequently (i.e. the tag can only be added once).
Workarounds I've Tried
suggestion
that returns an empty element. This doesn't work when there are no suggestions as theempty
template doesn't get rendered.Alternatives
One alternative would be to allow developers to override caching behaviour.
The text was updated successfully, but these errors were encountered: