Skip to content

Commit

Permalink
fix(ui5-icon): decorative icons now have aria-hidden=true (#3983)
Browse files Browse the repository at this point in the history
By design, decorative icons (role=presentation) should also have aria-hidden=true

Fixes: #3954
  • Loading branch information
dobrinyonkov committed Sep 29, 2021
1 parent fea941a commit 9101130
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/main/src/Icon.js
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

0 comments on commit 9101130

Please sign in to comment.