Skip to content

Commit 78cf6f3

Browse files
refactor(ui5-illustrated-message): aligned with ACC guidelines (#12743)
-Improved accessibility attributes for screen readers
1 parent 1d9b6ed commit 78cf6f3

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

packages/fiori/cypress/specs/IllustratedMessage.cy.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,40 @@ describe("Accessibility", () => {
3434
.should("not.have.attr", "aria-label");
3535

3636
});
37+
38+
it("should have role=img and aria-label with illustration name when decorative is false", () => {
39+
cy.mount(
40+
<IllustratedMessage name="UnableToUpload" decorative={false}>
41+
</IllustratedMessage>
42+
);
43+
44+
cy.get("[ui5-illustrated-message]")
45+
.shadow()
46+
.find(".ui5-illustrated-message-illustration")
47+
.should("have.attr", "role", "img");
48+
49+
cy.get("[ui5-illustrated-message]")
50+
.shadow()
51+
.find(".ui5-illustrated-message-illustration")
52+
.should("have.attr", "aria-label", "UnableToUpload");
53+
});
54+
55+
it("should have role=img and aria-label with illustration name by default (when decorative is not set)", () => {
56+
cy.mount(
57+
<IllustratedMessage name="NoData">
58+
</IllustratedMessage>
59+
);
60+
61+
cy.get("[ui5-illustrated-message]")
62+
.shadow()
63+
.find(".ui5-illustrated-message-illustration")
64+
.should("have.attr", "role", "img");
65+
66+
cy.get("[ui5-illustrated-message]")
67+
.shadow()
68+
.find(".ui5-illustrated-message-illustration")
69+
.should("have.attr", "aria-label", "NoData");
70+
});
3771
});
3872

3973
describe("design", () => {

packages/fiori/src/IllustratedMessageTemplate.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ export default function IllustratedMessageTemplate(this: IllustratedMessage) {
55
return (
66
<div class="ui5-illustrated-message-root">
77
<div class="ui5-illustrated-message-inner">
8-
<div class="ui5-illustrated-message-illustration">
8+
<div class="ui5-illustrated-message-illustration"
9+
role={this.decorative ? "presentation" : "img"}
10+
aria-hidden={this.decorative ? true : undefined}
11+
aria-label={!this.decorative ? this.name : undefined}>
912
{renderIllustration.call(this)}
1013
</div>
1114
<div class="ui5-illustrated-message-text-and-actions-container">

0 commit comments

Comments
 (0)