Skip to content

Commit

Permalink
fix(ui5-card): fix accessibiity role position (#10437)
Browse files Browse the repository at this point in the history
* fix(ui5-card): fix accessibiity role position

* fix(ui5-card): cypress tests added

* fix(ui5-card): optimized tests
  • Loading branch information
GerganaKremenska authored Jan 22, 2025
1 parent 5d4e3ba commit c9d7f3f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
51 changes: 51 additions & 0 deletions packages/main/cypress/specs/Card.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { html } from "lit";
import "../../src/Card.js";
import "../../src/CardHeader.js";

const interactiveCardHeader = html` <ui5-card>
<ui5-card-header
id="cardHeader1"
slot="header"
additional-text="4 of 10"
title-text="Quick Links"
subtitle-text="Quick links sub title"
interactive
>
</ui5-card-header>
</ui5-card>`;

const cardHeader = html` <ui5-card>
<ui5-card-header
id="cardHeader2"
slot="header"
additional-text="4 of 10"
title-text="Quick Links"
subtitle-text="Quick links sub title"
>
</ui5-card-header>
</ui5-card>`;

describe("Card header", () => {
it("Tests that aria attribute are correct on interactive header", () => {
cy.mount(interactiveCardHeader);

// assert
cy.get("#cardHeader1")
.shadow()
.find(".ui5-card-header-focusable-element")
.should("have.attr", "role", "button")
.and("have.attr", "tabindex", "0")
.and("have.attr", "aria-roledescription", "Interactive Card Header");
});
it("Tests that aria attribute are correct on a header", () => {
cy.mount(cardHeader);

// assert
cy.get("#cardHeader2")
.shadow()
.find(".ui5-card-header-focusable-element")
.should("have.attr", "role", "group")
.and("have.attr", "tabindex", "0")
.and("have.attr", "aria-roledescription", "Card Header");
});
});
2 changes: 1 addition & 1 deletion packages/main/src/CardHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class CardHeader extends UI5Element {
}

get ariaRoleFocusableElement() {
return this.interactive ? "button" : undefined;
return this.interactive ? "button" : "group";
}

get ariaCardAvatarLabel() {
Expand Down
3 changes: 1 addition & 2 deletions packages/main/src/CardHeaderTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ export default function CardHeaderTemplate(this: CardHeader) {
"ui5-card-header-ff": isFirefox(),
}}
part="root"
role="group"
aria-roledescription={this.ariaRoleDescription}
onClick={this._click}
onKeyDown={this._keydown}
onKeyUp={this._keyup}
>
<div
class="ui5-card-header-focusable-element"
aria-labelledby={this.ariaLabelledBy}
aria-roledescription={this.ariaRoleDescription}
role={this.ariaRoleFocusableElement}
data-sap-focus-ref
tabindex={0}
Expand Down

0 comments on commit c9d7f3f

Please sign in to comment.