Skip to content

FORMS-18673: Visual heading text is not marked as heading @sunnym @vavarshn #1563

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ui.frontend/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ export const Constants = {
*/
ARIA_CURRENT : "aria-current",

/**
* Role attribute.
* @type {string}
*/
ROLE : "role",

/**
* Prefix path for all AF HTTP APIs.
Expand Down
5 changes: 5 additions & 0 deletions ui.frontend/src/view/FormFieldBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ class FormFieldBase extends FormField {
this.toggleAttribute(this.label, label.visible, Constants.ARIA_HIDDEN, true);
this.label.setAttribute(Constants.DATA_ATTRIBUTE_VISIBLE, label.visible);
}

const bemClass = Array.from(this.element.classList).filter(bemClass => !bemClass.includes('--'))[0];
if (bemClass && this.label.parentElement.classList.contains(`${bemClass}__label-container`)) {
this.label.setAttribute(Constants.ROLE, "heading");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role="heading" is not required on a label container. Labels are already accessible using the for attribute and the corresponding id.

}
}
}

Expand Down
14 changes: 14 additions & 0 deletions ui.frontend/src/view/FormPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ class FormPanel extends FormFieldBase {
this.element.setAttribute(Constants.DATA_ATTRIBUTE_VALID, valid);
}

/**
* Updates the HTML state based on the label state of the field.
* @param {Object} label - The label.
*/
updateLabel(label) {
super.updateLabel(label);

const bemClass = Array.from(this.element.classList).filter(bemClass => !bemClass.includes('--'))[0];
const labelContainer = this.element.querySelector(`.${bemClass}__label-container`);
if (labelContainer) {
labelContainer.querySelector("label").setAttribute(Constants.ROLE, "heading");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role="heading" is not required on a label container. Labels are already accessible using the for attribute and the corresponding id.

}
}

/**
* Gets the child view at the specified index.
* This method needs to be implemented in every layout.
Expand Down
Loading