Skip to content

Commit 0352ff0

Browse files
authored
fix(ui5-avatar): fix accessibilityInfo for decorative mode (#13324)
1 parent f9ff5ee commit 0352ff0

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

packages/main/cypress/specs/Avatar.cy.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ describe("Accessibility", () => {
123123
});
124124

125125
// New tests for mode property
126+
it("mode='Decorative' returns empty accessibilityInfo", () => {
127+
cy.mount(
128+
<Avatar mode="Decorative" initials="JD" id="decorative-avatar"></Avatar>
129+
);
130+
cy.get("#decorative-avatar").then(($el) => {
131+
const avatar = $el[0] as any;
132+
expect(avatar.accessibilityInfo).to.deep.equal({});
133+
});
134+
});
135+
126136
it("mode='Decorative' renders with role='presentation' and aria-hidden", () => {
127137
cy.mount(
128138
<Avatar

packages/main/src/Avatar.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ class Avatar extends UI5Element implements ITabbable, IAvatarGroupItem {
540540
}
541541

542542
get accessibilityInfo() {
543+
if (this.mode === AvatarMode.Decorative) {
544+
return {};
545+
}
546+
543547
return {
544548
role: this._role as AriaRole,
545549
type: this._interactive ? Avatar.i18nBundle.getText(AVATAR_TYPE_BUTTON) : Avatar.i18nBundle.getText(AVATAR_TYPE_IMAGE),

0 commit comments

Comments
 (0)