-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
[Bug]: Dropdown with previous search filter retains cached options #694
Comments
Hey @jeremystretch. I'm currently facing the same issue, and as a "workaround" I'm fetching the data from remote each time the dropdown opens: new TomSelect('...', {
onDropdownOpen: function () {
this.clearOptions();
this.load();
},
load: function (query, callback) {
fetch(this.getUrl(query))
.then(response => response.json())
.then(data => {
callback(data.items);
})
.catch(() => {
callback();
});
}
}); For some reason, the built-in Additional checks can be provided to force fetching the remote data conditionally, but I haven't tested it, since in my case, I'm always fetching the data (due to other custom features that can change the URL of the remote). I've already spent enough time on this, if someone has more elegant solution, I'm all ears 😄 |
Bug description
I'm not sure if this is considered a bug, but I found it confusing for my use case.
I'm working with a TomSelect instance which queries a remote API to populate its options. When I enter search text, this is conveyed along with the API request so that only relevant responses are returned.
A problem arises when I enter search text, close the dropdown, and re-open it: The filtered set of options is still present, however the original filter text is not. There does not seem to be a way to clear or otherwise re-initialize the search without entering a new search filter.
For many use cases, this makes sense. However, when considering a use case where searching is optional, this is likely to confuse the user.
Expected behavior
IMO this could be improved by either:
Steps to reproduce
We can use the first example on this page (under "Ajax Loading") to observe the behavior.
django
.Additional context
The text was updated successfully, but these errors were encountered: