-
Notifications
You must be signed in to change notification settings - Fork 64
FORMS-18671: Visible label missing @sunnym @vavarshn #1603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 1 commit
c4755fc
8856026
e53cbe2
9fdab17
0f1f005
55f3648
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,20 +35,22 @@ | |
| <div data-sly-call="${questionMark.questionMark @componentId=file.id, longDescription=file.description, bemBlock='cmp-adaptiveform-fileinput'}" data-sly-unwrap></div> | ||
| </div> | ||
| </br> | ||
| <label data-sly-test="${file.buttonText}" for="${file.id}_widget" tabindex="0" role="button" class="cmp-adaptiveform-fileinput__widgetlabel">${file.buttonText}</label> | ||
| <input class="cmp-adaptiveform-fileinput__widget" | ||
| data-sly-attribute.multiple="${file.isMultiple ? 'multiple' : ''}" | ||
| style="${file.buttonText ? 'display:none' : '' @ context='styleString'}" | ||
| title="${file.tooltipVisible ? '' : file.tooltipText}" | ||
| name="${file.name}" | ||
| disabled="${!file.enabled}" | ||
| required="${file.required}" | ||
| accept="${file.accept}" | ||
| id="${file.id}_widget" | ||
| type="file" | ||
| aria-describedby="${file.id}__errormessage ${file.id}__longdescription ${file.id}__shortdescription" | ||
| data-cmp-data-layer="${file.data.json}" | ||
| /> | ||
| <div class="cmp-adaptiveform-fileinput__widget-container"> | ||
|
||
| <label data-sly-test="${file.buttonText}" for="${file.id}_widget" tabindex="0" role="button" class="cmp-adaptiveform-fileinput__widgetlabel">${file.buttonText}</label> | ||
| <input class="cmp-adaptiveform-fileinput__widget" | ||
| data-sly-attribute.multiple="${file.isMultiple ? 'multiple' : ''}" | ||
| style="${file.buttonText ? 'display:none' : '' @ context='styleString'}" | ||
| title="${file.tooltipVisible ? '' : file.tooltipText}" | ||
| name="${file.name}" | ||
| disabled="${!file.enabled}" | ||
| required="${file.required}" | ||
| accept="${file.accept}" | ||
| id="${file.id}_widget" | ||
| type="file" | ||
| aria-describedby="${file.id}__errormessage ${file.id}__longdescription ${file.id}__shortdescription" | ||
| data-cmp-data-layer="${file.data.json}" | ||
| /> | ||
| </div> | ||
| <ul class="cmp-adaptiveform-fileinput__filelist"></ul> | ||
| <div data-sly-call="${shortDescription.shortDescription @componentId=file.id, shortDescriptionVisible=file.tooltipVisible, shortDescription=file.tooltip, bemBlock='cmp-adaptiveform-fileinput'}" data-sly-unwrap> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,27 +35,29 @@ | |
| <div data-sly-call="${label.label @componentId=tnc.id, labelValue=tnc.label.value, labelVisible=tnc.label.visible, labelRichText=tnc.label.richText, bemBlock='cmp-adaptiveform-termsandcondition'}" data-sly-unwrap></div> | ||
| <div data-sly-call="${questionMark.questionMark @componentId=tnc.id, longDescription=tnc.description, bemBlock='cmp-adaptiveform-termsandcondition'}" data-sly-unwrap></div> | ||
| </div> | ||
| <div class="cmp-adaptiveform-termsandcondition__content-container ${!wcmmode.edit && tnc.showAsPopup ? 'cmp-adaptiveform-termsandcondition__content-container--modal' : ''}" | ||
| data-cmp-visible="${tnc.showAsPopup ? 'false' : 'true'}"> | ||
| <div class="cmp-adaptiveform-termsandcondition__body"> | ||
| <div class="cmp-adaptiveform-termsandcondition__header" data-sly-test="${tnc.showAsPopup && !wcmmode.edit}"> | ||
| <button type="button" class="cmp-adaptiveform-termsandcondition__close-button" > | ||
| X | ||
| </button> | ||
| <h3> | ||
| ${"Please review the terms and conditions" @ i18n, context='html'} | ||
| </h3> | ||
| </div> | ||
| <div class="cmp-adaptiveform-termsandcondition__content"> | ||
| <div data-sly-test="${!tnc.showLink}" class="cmp-adaptiveform-termsandcondition__text"> | ||
| <div data-sly-resource="${'text'}"></div> | ||
| <div class="cmp-adaptiveform-termsandcondition__text-intersect"></div> | ||
| <div class="cmp-adaptiveform-termsandcondition__widget-container"> | ||
|
||
| <div class="cmp-adaptiveform-termsandcondition__content-container ${!wcmmode.edit && tnc.showAsPopup ? 'cmp-adaptiveform-termsandcondition__content-container--modal' : ''}" | ||
| data-cmp-visible="${tnc.showAsPopup ? 'false' : 'true'}"> | ||
| <div class="cmp-adaptiveform-termsandcondition__body"> | ||
| <div class="cmp-adaptiveform-termsandcondition__header" data-sly-test="${tnc.showAsPopup && !wcmmode.edit}"> | ||
| <button type="button" class="cmp-adaptiveform-termsandcondition__close-button" > | ||
| X | ||
| </button> | ||
| <h3> | ||
| ${"Please review the terms and conditions" @ i18n, context='html'} | ||
| </h3> | ||
| </div> | ||
| <div class="cmp-adaptiveform-termsandcondition__content"> | ||
| <div data-sly-test="${!tnc.showLink}" class="cmp-adaptiveform-termsandcondition__text"> | ||
| <div data-sly-resource="${'text'}"></div> | ||
| <div class="cmp-adaptiveform-termsandcondition__text-intersect"></div> | ||
| </div> | ||
| <div class="cmp-adaptiveform-termsandcondition__link" data-sly-test="${tnc.showLink}" data-sly-resource="${'link'}"></div> | ||
| </div> | ||
| <div class="cmp-adaptiveform-termsandcondition__link" data-sly-test="${tnc.showLink}" data-sly-resource="${'link'}"></div> | ||
| </div> | ||
| </div> | ||
| <div class="cmp-adaptiveform-termsandcondition__approvalcheckbox" data-sly-test="${tnc.showApprovalOption}" data-sly-resource="${'approvalcheckbox'}"></div> | ||
| </div> | ||
| <div class="cmp-adaptiveform-termsandcondition__approvalcheckbox" data-sly-test="${tnc.showApprovalOption}" data-sly-resource="${'approvalcheckbox'}"></div> | ||
| <div data-sly-call="${shortDescription.shortDescription @componentId=tnc.id, shortDescriptionVisible=tnc.tooltipVisible, shortDescription=tnc.tooltip, bemBlock='cmp-adaptiveform-termsandcondition'}" data-sly-unwrap></div> | ||
| <div data-sly-call="${longDescription.longDescription @componentId=tnc.id, longDescription=tnc.description, bemBlock='cmp-adaptiveform-termsandcondition'}" data-sly-unwrap></div> | ||
| </div> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,15 +229,25 @@ class FormFieldBase extends FormField { | |
| } | ||
|
|
||
| #syncAriaLabel() { | ||
| const bemClass = Array.from(this.element.classList).filter(bemClass => !bemClass.includes('--'))[0]; | ||
| const regionContainer = this.element.querySelector(`.${bemClass}__widget-container`); | ||
| let widgetElement = typeof this.getWidget === 'function' ? this.getWidget() : null; | ||
| let widgetElements = typeof this.getWidgets === 'function' ? this.getWidgets() : null; | ||
| widgetElement = widgetElements || widgetElement; | ||
| const model = this.getModel?.(); | ||
|
|
||
| if (widgetElement && model?.screenReaderText) { | ||
| if (model?.screenReaderText){ | ||
| // Use DOMPurify to sanitize and strip HTML tags | ||
| const screenReaderText = window.DOMPurify ? window.DOMPurify.sanitize(model.screenReaderText, { ALLOWED_TAGS: [] }) : model.screenReaderText; | ||
| widgetElement.setAttribute('aria-label', screenReaderText); | ||
|
|
||
| // Some elements have the Widget hidden by default and other are Panels | ||
| // So this container mimics having a single, showing widget to attach the Accessibility label to. | ||
| if(regionContainer) { | ||
| regionContainer.setAttribute('role', 'region'); | ||
|
||
| regionContainer.setAttribute('aria-label', screenReaderText); | ||
| } else if (widgetElement) { | ||
| widgetElement.setAttribute('aria-label', screenReaderText); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -249,7 +259,7 @@ class FormFieldBase extends FormField { | |
| this.#syncLabel() | ||
| this.#syncWidget() | ||
| this.#syncShortDesc() | ||
| this. #syncLongDesc() | ||
| this.#syncLongDesc() | ||
| this.#syncAriaDescribedBy() | ||
| this.#syncError() | ||
| this.#syncAriaLabel() | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add the role="group" attribute, you must connect the label to the group using the aria-labelledby attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added logic in FormFieldBase.js for this. Should help both CheckboxGroup and RadioGroup.