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 authored and ilhan007 committed Oct 3, 2021
1 parent 2379c97 commit e558159
Showing 1 changed file with 11 additions and 1 deletion.
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 @@ -257,6 +259,10 @@ class Icon extends UI5Element {

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

return;
}

Expand All @@ -267,6 +273,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 @@ -276,7 +286,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 e558159

Please sign in to comment.