From d01d1e78c208fa917657bf1175188eb5a750231b Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Mon, 1 Aug 2022 09:47:13 +0200 Subject: [PATCH] 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 --- .../ve.ui.MWTransclusionOutlineButtonWidget.js | 4 ++++ ....MWTransclusionOutlineParameterSelectWidget.js | 15 ++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineButtonWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineButtonWidget.js index 6d31dc1b4e..244729e7b2 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineButtonWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineButtonWidget.js @@ -4,6 +4,10 @@ * * @class * @extends OO.ui.OptionWidget + * @mixins OO.ui.mixin.ButtonElement + * @mixins OO.ui.mixin.IconElement + * @mixins OO.ui.mixin.TabIndexedElement + * @mixins ve.ui.MWAriaDescribe * * @constructor * @param {Object} config diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js index 4ee28190a2..d1bc344db3 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js @@ -8,6 +8,8 @@ * * @class * @extends OO.ui.SelectWidget + * @mixins OO.ui.mixin.TabIndexedElement + * @mixins ve.ui.MWAriaDescribe * * @constructor * @param {Object} config @@ -92,17 +94,8 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.addItems = function ( * @return {ve.ui.MWTransclusionOutlineParameterWidget|null} */ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.findFirstSelectedItem = function () { - var firstSelected; - - this.items.some( function ( item ) { - if ( !firstSelected && item.isSelected() ) { - firstSelected = item; - return true; - } - return false; - } ); - - return firstSelected; + var selected = this.findSelectedItems(); + return Array.isArray( selected ) ? selected[ 0 ] || null : selected; }; /**