Skip to content

Commit 1594186

Browse files
authored
fix(ui5-carousel): update roles to match ACC specification (#11032)
JIRA: BGSOFUIRODOPI-3382 fixes #10198 fixes #8624
1 parent 8643afe commit 1594186

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Carousel from "../../src/Carousel.js";
2+
import Text from "../../src/Text.js";
3+
4+
describe("Accessibility", () => {
5+
it("tests carousel aria roles", () => {
6+
cy.mount(
7+
<Carousel id="carousel">
8+
<Text id="text">Test</Text>
9+
</Carousel>
10+
);
11+
12+
cy.get("#carousel")
13+
.shadow()
14+
.find(".ui5-carousel-root")
15+
.should("have.attr", "role", "list");
16+
17+
cy.get("#carousel")
18+
.shadow()
19+
.find(".ui5-carousel-item")
20+
.should("have.attr", "role", "listitem");
21+
22+
cy.get("#carousel")
23+
.shadow()
24+
.find(".ui5-carousel-root")
25+
.should("have.attr", "aria-roledescription", "Carousel");
26+
});
27+
});

packages/main/src/Carousel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
CAROUSEL_DOT_TEXT,
2828
CAROUSEL_PREVIOUS_ARROW_TEXT,
2929
CAROUSEL_NEXT_ARROW_TEXT,
30+
CAROUSEL_ARIA_ROLE_DESCRIPTION,
3031
} from "./generated/i18n/i18n-defaults.js";
3132
import CarouselArrowsPlacement from "./types/CarouselArrowsPlacement.js";
3233
import CarouselPageIndicatorType from "./types/CarouselPageIndicatorType.js";
@@ -700,6 +701,10 @@ class Carousel extends UI5Element {
700701
return Carousel.i18nBundle.getText(CAROUSEL_PREVIOUS_ARROW_TEXT);
701702
}
702703

704+
get _roleDescription() {
705+
return Carousel.i18nBundle.getText(CAROUSEL_ARIA_ROLE_DESCRIPTION);
706+
}
707+
703708
/**
704709
* The indices of the currently visible items of the component.
705710
* @public

packages/main/src/CarouselTemplate.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export default function CarouselTemplate(this: Carousel) {
1111
[`ui5-carousel-background-${this._backgroundDesign}`]: true,
1212
}}
1313
tabindex={0}
14-
role="listbox"
14+
role="list"
1515
aria-label={this.ariaLabelTxt}
16+
aria-roledescription={this._roleDescription}
1617
aria-activedescendant={this.ariaActiveDescendant}
1718
onFocusIn={this._onfocusin}
1819
onKeyDown={this._onkeydown}
@@ -30,7 +31,7 @@ export default function CarouselTemplate(this: Carousel) {
3031
}}
3132
style={{ width: `${this._itemWidth || 0}px` }}
3233
part="item"
33-
role="option"
34+
role="listitem"
3435
aria-posinset={itemInfo.posinset}
3536
aria-setsize={itemInfo.setsize}
3637
aria-selected = {itemInfo.selected}

packages/main/src/i18n/messagebundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ CAROUSEL_PREVIOUS_ARROW_TEXT=Previous Page
103103
# Carousel Next Page text
104104
CAROUSEL_NEXT_ARROW_TEXT=Next Page
105105

106+
#XACT: ARIA announcement for the ettribute 'aria-roledescription' of the Carousel component
107+
CAROUSEL_ARIA_ROLE_DESCRIPTION=Carousel
108+
106109
#XFLD: Label of the container holding the colors
107110
COLORPALETTE_CONTAINER_LABEL=Color palette - Predefined colors
108111

0 commit comments

Comments
 (0)