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

Change subject: FieldLayout: Set 'aria-describedby' on the fieldWidget
......................................................................


FieldLayout: Set 'aria-describedby' on the fieldWidget

Follows the ARIA pattern as described in:
https://www.w3.org/TR/WCAG20-TECHS/ARIA1.html

Bug: T97957
Change-Id: I8fd845700aabdcc46878e381d9f4610f1d4651c1
---
M src/layouts/FieldLayout.js
M src/widgets/PopupWidget.js
2 files changed, 27 insertions(+), 0 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, but someone else must approve
  jenkins-bot: Verified
  VolkerE: Looks good to me, approved



diff --git a/src/layouts/FieldLayout.js b/src/layouts/FieldLayout.js
index 2bbe48a..8a606d5 100644
--- a/src/layouts/FieldLayout.js
+++ b/src/layouts/FieldLayout.js
@@ -97,6 +97,18 @@
        this.fieldWidget.connect( this, { disable: 'onFieldDisable' } );
 
        // Initialization
+       if ( config.help ) {
+               // Set the 'aria-describedby' attribute on the fieldWidget
+               // Preference given to an input or a button
+               (
+                       this.fieldWidget.$input ||
+                       this.fieldWidget.$button ||
+                       this.fieldWidget.$element
+               ).attr(
+                       'aria-describedby',
+                       this.popupButtonWidget.getPopup().getBodyId()
+               );
+       }
        if ( this.fieldWidget.getInputId() ) {
                this.$label.attr( 'for', this.fieldWidget.getInputId() );
        } else {
diff --git a/src/widgets/PopupWidget.js b/src/widgets/PopupWidget.js
index c9f2658..a35a1ec 100644
--- a/src/widgets/PopupWidget.js
+++ b/src/widgets/PopupWidget.js
@@ -576,3 +576,18 @@
 OO.ui.PopupWidget.prototype.getPosition = function () {
        return this.popupPosition;
 };
+
+/**
+ * Get an ID of the body element, this can be used as the
+ * `aria-describedby` attribute for an input field.
+ *
+ * @return {string} The ID of the body element
+ */
+OO.ui.PopupWidget.prototype.getBodyId = function () {
+       var id = this.$body.attr( 'id' );
+       if ( id === undefined ) {
+               id = OO.ui.generateElementId();
+               this.$body.attr( 'id', id );
+       }
+       return id;
+};

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8fd845700aabdcc46878e381d9f4610f1d4651c1
Gerrit-PatchSet: 2
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <psax...@wikimedia.org>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com>
Gerrit-Reviewer: VolkerE <volke...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to