- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Reselecting a removed item in a multiple selectbox have 'active' class #1212
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
Comments
It looks like this is caused by the render cache. When an item is rendered the rendered HTML is stored in a cache. When an item is selected the render cache is updated with the When a selected item is removed it is removed from the One can fix (read: patch) this by defining a plugin that removes the render cache when an item is removed: function clearRemovedItemCacheSelectizePlugin() {
const self = this;
this.removeItem = (function () {
const original = self.removeItem;
return function (...args) {
original.apply(self, args);
const [value] = args;
if (self.renderCache && self.renderCache.item) {
delete self.renderCache.item[value];
}
};
}());
}
Selectize.define('clear_removed_item_cache', clearRemovedItemCacheSelectizePlugin); Obviously this should be fixed through a PR, but it doesn't look like this repo is very active. |
@quintstoffers I'll accept a PR if it is easy to accept. I don't have all the context to understand the exact issue, but if it's an issue in core, it should be fixed. |
I have a feeling the problem is caused by the render cache being passed a reference to the generated element. Whenever you modify the element the cached element is modified as well. I haven't actually tested this, so perhaps I'm wrong. If I'm right passing a copy of the rendered element to the cache should fix the problem, but it could possibly break other things. Removing the |
I fixed this by overwriting the
|
…and then re-added in "multiple" mode Fixes selectize#1212 and selectize#1216.
…and then re-added in "multiple" mode Fixes issues selectize#1212 and selectize#1216.
…and then re-added in "multiple" mode Fixes issues selectize#1212 and selectize#1216.
…and then re-added in "multiple" mode Fixes issues selectize#1212 and selectize#1216.
closing stale issues older than one year. |
@risadams This is still an issue (with an available PR to fix it). I recommend reopening. |
I did:
[X] Search for if my issue has already been submitted
[X] Make sure I'm reporting something precise that needs to be fixed
[X] Give my issue a descriptive and concise title
[ ] Create a minimal working example on JsFiddle or Codepen
[X] Indicate precise steps to reproduce in numbers and the result,
like below
Steps to reproduce:
Please let me know if you need more explanation. Thanks!
PS I love this Awesome plugin!!
The text was updated successfully, but these errors were encountered: