Merge "RCFilters UI: Prevent label from stealing focus on click"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 18 Apr 2017 00:26:47 +0000 (00:26 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 18 Apr 2017 00:26:47 +0000 (00:26 +0000)
1  2 
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js

         */
        mw.rcfilters.ui.FilterTagMultiselectWidget.prototype.onMenuChoose = function ( item ) {
                this.controller.toggleFilterSelect( item.model.getName() );
+               this.focus();
        };
  
        /**
         */
        mw.rcfilters.ui.FilterTagMultiselectWidget.prototype.onTagSelect = function ( tagItem ) {
                var widget = this,
 -                      menuOption = this.menu.getItemFromData( tagItem.getData() );
 +                      menuOption = this.menu.getItemFromData( tagItem.getData() ),
 +                      oldInputValue = this.input.getValue();
  
                // Reset input
                this.input.setValue( '' );
                this.menu.selectItem( menuOption );
  
                // Scroll to the item
 -              // 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
 -              // user filtered the results
 -              this.getMenu().once(
 -                      'itemVisibilityChange',
 -                      function () { widget.scrollToTop( menuOption.$element ); }
 -              );
 +              if ( 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
 +                      // user filtered the results
 +                      this.getMenu().once(
 +                              'itemVisibilityChange',
 +                              function () { widget.scrollToTop( menuOption.$element ); }
 +                      );
 +              } else {
 +                      this.scrollToTop( menuOption.$element );
 +              }
        };
  
        /**