From: Roan Kattouw Date: Fri, 6 Jan 2017 23:59:48 +0000 (-0800) Subject: RCFilters: Clean up focus handling in capsule widget X-Git-Tag: 1.31.0-rc.0~4301^2 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=3cd8c25fa5b75c02a6809efb91bc1fbb60659b66;p=lhc%2Fweb%2Fwiklou.git RCFilters: Clean up focus handling in capsule widget Don't let the parent class's weird implementation run when the widget is focused through other code paths (e.g. clicking on the non-input part of it). We still need to fix the behavior when you click in the input twice (the first click shows the popup and the second click hides it), but this is much better already. Related to I21b8cff4048 in oojs-ui. Bug: T149452 Change-Id: I08743c64ea32feace757e2a8626df2f5310cfbc9 --- diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js index df6cf8b7d5..db2154231b 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterCapsuleMultiselectWidget.js @@ -25,7 +25,7 @@ // Events // Add the filterInput as trigger this.filterInput.$input - .on( 'focus', this.onFocusForPopup.bind( this ) ); + .on( 'focus', this.focus.bind( this ) ); this.$element .addClass( 'mw-rcfilters-ui-filterCapsuleMultiselectWidget' ); @@ -49,12 +49,22 @@ /** * @inheritdoc */ - mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onFocusForPopup = function () { + mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.focus = function () { // Override this method; we don't want to focus on the popup, and we // don't want to bind the size to the handle. if ( !this.isDisabled() ) { this.popup.toggle( true ); + this.filterInput.$input.get( 0 ).focus(); } + return this; + }; + + /** + * @inheritdoc + */ + mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onFocusForPopup = function () { + // HACK can be removed once I21b8cff4048 is merged in oojs-ui + this.focus(); }; /**