RCFilters: Remove view triggers before checking emptiness of string
authorMoriel Schottlender <moriel@gmail.com>
Wed, 21 Jun 2017 20:31:35 +0000 (13:31 -0700)
committerMoriel Schottlender <moriel@gmail.com>
Thu, 22 Jun 2017 00:16:28 +0000 (17:16 -0700)
Bug: T168220
Change-Id: I3ae6fba358456745cb570840211319f7eac754ce

resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js

index ebffaa0..d84a00a 100644 (file)
                        filterItem.clearHighlightColor();
                } );
        };
+
+       /**
+        * Return a version of the given string that is without any
+        * view triggers.
+        *
+        * @param {string} str Given string
+        * @return {string} Result
+        */
+       mw.rcfilters.dm.FiltersViewModel.prototype.removeViewTriggers = function ( str ) {
+               if ( this.getViewByTrigger( str.substr( 0, 1 ) ) !== 'default' ) {
+                       str = str.substr( 1 );
+               }
+
+               return str;
+       };
 }( mediaWiki, jQuery ) );
index 268138f..025adea 100644 (file)
                this.selectTag( tagItem );
 
                // Scroll to the item
-               if ( oldInputValue ) {
+               if ( this.model.removeViewTriggers( oldInputValue ) ) {
                        // We're binding a 'once' to the itemVisibilityChange event
                        // so this happens when the menu is ready after the items
                        // are visible again, in case this is done right after the