From abeb8dc28468f436e8b3ea663a5739714f810137 Mon Sep 17 00:00:00 2001 From: Kosta Harlan Date: Tue, 26 Jun 2018 16:24:11 -0400 Subject: [PATCH] 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 --- .../ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 ) ); } -- 2.20.1