From: Kosta Harlan Date: Tue, 26 Jun 2018 20:24:11 +0000 (-0400) Subject: RCFilters: Only attempt to remove tag if we can find an item for it X-Git-Tag: 1.34.0-rc.0~4953 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=abeb8dc28468f436e8b3ea663a5739714f810137;p=lhc%2Fweb%2Fwiklou.git RCFilters: Only attempt to remove tag if we can find an item for it As noted in T198140 and T198231, removeTagByData leads us eventually to OO.ui.mixin.GroupElement.prototype.removeItems(), which does not check if any of the items are null values, and a change event is emitted. This commit ensures that we can find an item for the data before attempting to remove the tag. Bug: T198140 Change-Id: I79a923a7b4e5f6c4d14fcce3c5855b4c56796384 --- diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js index d59fdfb45c..907c5354a1 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js @@ -476,7 +476,10 @@ ) { this.addTag( item.getName(), item.getLabel() ); } else { - this.removeTagByData( item.getName() ); + // Only attempt to remove the tag if we can find an item for it (T198140, T198231) + if ( this.findItemFromData( item.getName() ) !== null ) { + this.removeTagByData( item.getName() ); + } } } @@ -525,7 +528,10 @@ // Remove capsule widgets if they're not selected highlightedItems.forEach( function ( filterItem ) { if ( !filterItem.isSelected() ) { - this.removeTagByData( filterItem.getName() ); + // Only attempt to remove the tag if we can find an item for it (T198140, T198231) + if ( this.findItemFromData( filterItem.getName() ) !== null ) { + this.removeTagByData( filterItem.getName() ); + } } }.bind( this ) ); }