jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/331588 )

Change subject: CapsuleMultiselectWidget: Make labels work
......................................................................


CapsuleMultiselectWidget: Make labels work

Also, don't add a useless 'for' attribute on the label if 'getInputId'
returns false.

Bug: T148946
Change-Id: I7da27202f771948c259cba959b99c322b9563080
---
M src/layouts/FieldLayout.js
M src/widgets/CapsuleMultiselectWidget.js
M src/widgets/LabelWidget.js
3 files changed, 30 insertions(+), 2 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/layouts/FieldLayout.js b/src/layouts/FieldLayout.js
index ee6a34c..ed0387c 100644
--- a/src/layouts/FieldLayout.js
+++ b/src/layouts/FieldLayout.js
@@ -95,7 +95,9 @@
 
        // Initialization
        if ( fieldWidget.constructor.static.supportsSimpleLabel ) {
-               this.$label.attr( 'for', this.fieldWidget.getInputId() );
+               if ( this.fieldWidget.getInputId() ) {
+                       this.$label.attr( 'for', this.fieldWidget.getInputId() 
);
+               }
        }
        this.$element
                .addClass( 'oo-ui-fieldLayout' )
diff --git a/src/widgets/CapsuleMultiselectWidget.js 
b/src/widgets/CapsuleMultiselectWidget.js
index f263b9d..c0d32e3 100644
--- a/src/widgets/CapsuleMultiselectWidget.js
+++ b/src/widgets/CapsuleMultiselectWidget.js
@@ -206,6 +206,10 @@
 OO.mixinClass( OO.ui.CapsuleMultiselectWidget, OO.ui.mixin.IndicatorElement );
 OO.mixinClass( OO.ui.CapsuleMultiselectWidget, OO.ui.mixin.IconElement );
 
+/* Static Properties */
+
+OO.ui.CapsuleMultiselectWidget.static.supportsSimpleLabel = true;
+
 /* Events */
 
 /**
@@ -242,6 +246,26 @@
 };
 
 /**
+ * Get the widget's input's id, or generate one, if it has an input.
+ *
+ * @return {string}
+ */
+OO.ui.CapsuleMultiselectWidget.prototype.getInputId = function () {
+       var id;
+       if ( !this.$input ) {
+               return false;
+       }
+
+       id = this.$input.attr( 'id' );
+       if ( id === undefined ) {
+               id = OO.ui.generateElementId();
+               this.$input.attr( 'id', id );
+       }
+
+       return id;
+};
+
+/**
  * Get the data of the items in the capsule
  *
  * @return {Mixed[]}
diff --git a/src/widgets/LabelWidget.js b/src/widgets/LabelWidget.js
index c2f2336..1ec41fb 100644
--- a/src/widgets/LabelWidget.js
+++ b/src/widgets/LabelWidget.js
@@ -53,7 +53,9 @@
 
        // Initialization
        if ( this.input instanceof OO.ui.InputWidget ) {
-               this.$element.attr( 'for', this.input.getInputId() );
+               if ( this.input.getInputId() ) {
+                       this.$element.attr( 'for', this.input.getInputId() );
+               }
        }
        this.$element.addClass( 'oo-ui-labelWidget' );
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/331588
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7da27202f771948c259cba959b99c322b9563080
Gerrit-PatchSet: 13
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Prtksxna <[email protected]>
Gerrit-Reviewer: VolkerE <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to