Simplify partly redundant findFirstSelectedItem implementation

Introduced via Ibc56abf. But the OOUI SelectWidget does have some
methods for this already.

This patch also updates some @mixins documentation.

Bug: T302965
Change-Id: Iffbb44d41586786a2165f8d7916f94a52ad19122
This commit is contained in:
Thiemo Kreuz 2022-08-01 09:47:13 +02:00 committed by Thiemo Kreuz (WMDE)
parent 799c0b86ea
commit d01d1e78c2
2 changed files with 8 additions and 11 deletions

View file

@ -4,6 +4,10 @@
* *
* @class * @class
* @extends OO.ui.OptionWidget * @extends OO.ui.OptionWidget
* @mixins OO.ui.mixin.ButtonElement
* @mixins OO.ui.mixin.IconElement
* @mixins OO.ui.mixin.TabIndexedElement
* @mixins ve.ui.MWAriaDescribe
* *
* @constructor * @constructor
* @param {Object} config * @param {Object} config

View file

@ -8,6 +8,8 @@
* *
* @class * @class
* @extends OO.ui.SelectWidget * @extends OO.ui.SelectWidget
* @mixins OO.ui.mixin.TabIndexedElement
* @mixins ve.ui.MWAriaDescribe
* *
* @constructor * @constructor
* @param {Object} config * @param {Object} config
@ -92,17 +94,8 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.addItems = function (
* @return {ve.ui.MWTransclusionOutlineParameterWidget|null} * @return {ve.ui.MWTransclusionOutlineParameterWidget|null}
*/ */
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.findFirstSelectedItem = function () { ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.findFirstSelectedItem = function () {
var firstSelected; var selected = this.findSelectedItems();
return Array.isArray( selected ) ? selected[ 0 ] || null : selected;
this.items.some( function ( item ) {
if ( !firstSelected && item.isSelected() ) {
firstSelected = item;
return true;
}
return false;
} );
return firstSelected;
}; };
/** /**