diff options
author | James D. Forrester <jforrester@wikimedia.org> | 2021-03-12 14:01:05 -0800 |
---|---|---|
committer | James D. Forrester <jforrester@wikimedia.org> | 2021-03-12 14:01:05 -0800 |
commit | dcc67bd33a77ec9a67bc56fd0e391f496a70348b (patch) | |
tree | a1a006006e740a981e050d942892a7ab83deeb79 /resources/lib/ooui/oojs-ui-widgets.js | |
parent | 54ae1028b0408b4a020bd73ad929bcf6c7db340a (diff) | |
download | mediawikicore-dcc67bd33a77ec9a67bc56fd0e391f496a70348b.tar.gz mediawikicore-dcc67bd33a77ec9a67bc56fd0e391f496a70348b.zip |
Update OOUI to v0.41.3
Release notes:
https://gerrit.wikimedia.org/g/oojs/ui/+/v0.41.3/History.md
Bug: T230066
Bug: T262973
Bug: T277177
Change-Id: Ic1ebc506a66d90658e488c5a8bebfeaadb9a83ce
Depends-On: I7aca10091f6a024190781bc3487771201e3c1c62
Diffstat (limited to 'resources/lib/ooui/oojs-ui-widgets.js')
-rw-r--r-- | resources/lib/ooui/oojs-ui-widgets.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/resources/lib/ooui/oojs-ui-widgets.js b/resources/lib/ooui/oojs-ui-widgets.js index 01a6ce5df0f4..3d151a0bc5f7 100644 --- a/resources/lib/ooui/oojs-ui-widgets.js +++ b/resources/lib/ooui/oojs-ui-widgets.js @@ -1,12 +1,12 @@ /*! - * OOUI v0.41.2 + * OOUI v0.41.3 * https://www.mediawiki.org/wiki/OOUI * * Copyright 2011–2021 OOUI Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2021-03-09T16:32:17Z + * Date: 2021-03-12T21:47:47Z */ ( function ( OO ) { @@ -4651,6 +4651,11 @@ OO.ui.TagMultiselectWidget.prototype.onInputFocus = function () { * Respond to input blur event */ OO.ui.TagMultiselectWidget.prototype.onInputBlur = function () { + // Skip of blur was triggered by DOM re-ordering in onChangeTags + if ( this.changing ) { + return; + } + this.$element.removeClass( 'oo-ui-tagMultiselectWidget-focus' ); // Set the widget as invalid if there's text in the input @@ -4774,7 +4779,10 @@ OO.ui.TagMultiselectWidget.prototype.onTagFixed = function ( item ) { * Respond to change event, where items were added, removed, or cleared. */ OO.ui.TagMultiselectWidget.prototype.onChangeTags = function () { - var isUnderLimit = this.isUnderLimit(); + var hadFocus, + isUnderLimit = this.isUnderLimit(); + + this.changing = true; // Reset validity this.toggleValid( this.checkValidity() ); @@ -4791,13 +4799,19 @@ OO.ui.TagMultiselectWidget.prototype.onChangeTags = function () { this.input.$input.attr( 'placeholder', isUnderLimit ? this.inputPlaceholder : '' ); this.input.setDisabled( !isUnderLimit ); } else { + hadFocus = document.activeElement === this.input.$input[ 0 ]; // Move input to the end of the group this.$group.append( this.input.$input ); // Show/hide the input this.input.$input.toggleClass( 'oo-ui-element-hidden', !isUnderLimit ); + if ( hadFocus && isUnderLimit ) { + this.input.focus(); + } } } this.updateIfHeightChanged(); + + this.changing = false; }; /** @@ -4811,7 +4825,7 @@ OO.ui.TagMultiselectWidget.prototype.setDisabled = function ( isDisabled ) { if ( !isDisabled ) { this.updateInputSize(); } - this.input.setDisabled( !!isDisabled && !this.isUnderLimit() ); + this.input.setDisabled( !!isDisabled || !this.isUnderLimit() ); } if ( this.items ) { @@ -6284,8 +6298,11 @@ OO.ui.SearchWidget.prototype.onQueryKeydown = function ( e ) { highlightedItem = this.results.findSelectedItem(); } nextItem = this.results.findRelativeSelectableItem( highlightedItem, dir ); + // nextItem may be null if there are no results this.results.highlightItem( nextItem ); - nextItem.scrollElementIntoView(); + if ( nextItem ) { + nextItem.scrollElementIntoView(); + } } }; |