From: Moriel Schottlender Date: Mon, 17 Apr 2017 23:30:03 +0000 (-0700) Subject: RCFilters UI: Fix scrolling to item on tag click X-Git-Tag: 1.31.0-rc.0~3488^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=d490e69b9ee54ce0b950170c8051b3eb6018d4e7;p=lhc%2Fweb%2Fwiklou.git RCFilters UI: Fix scrolling to item on tag click Bug: T163138 Change-Id: I1f3a5b29eb3d9125faf1d4d27c84b8711fd4fdda --- 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 246192970c..7de2a79e94 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js @@ -236,7 +236,8 @@ */ 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( '' ); @@ -247,14 +248,18 @@ 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 ); + } }; /**