Skip to content
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

fix(ui5-icon): decorative icons now have aria-hidden=true #3983

Merged
merged 1 commit into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/main/src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import IconTemplate from "./generated/templates/IconTemplate.lit.js";
import iconCss from "./generated/themes/Icon.css.js";

const ICON_NOT_FOUND = "ICON_NOT_FOUND";
const PRESENTATION_ROLE = "presentation";

/**
* @public
Expand Down Expand Up @@ -97,6 +98,7 @@ const metadata = {

/**
* Defines the aria hidden state of the component.
* Note: If the role is presentation the default value of aria-hidden will be true.
* @private
* @since 1.0.0-rc.15
*/
Expand Down Expand Up @@ -267,6 +269,10 @@ class Icon extends UI5Element {

get effectiveAriaHidden() {
if (this.ariaHidden === "") {
if (this.isDecorative) {
return true;
}

return;
}

Expand All @@ -277,6 +283,10 @@ class Icon extends UI5Element {
return this.interactive ? "0" : "-1";
}

get isDecorative() {
return this.effectiveAccessibleRole === PRESENTATION_ROLE;
}

get effectiveAccessibleRole() {
if (this.role) {
return this.role;
Expand All @@ -286,7 +296,7 @@ class Icon extends UI5Element {
return "button";
}

return this.effectiveAccessibleName ? "img" : "presentation";
return this.effectiveAccessibleName ? "img" : PRESENTATION_ROLE;
}

static createGlobalStyle() {
Expand Down