Skip to content

Commit fa59293

Browse files
fix(ui5-carousel): add aria-label to the list element (#12587)
* fix(ui5-carousel): add correct aria-label to the list element
1 parent 0b0b516 commit fa59293

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ describe("Carousel general interaction", () => {
252252
.find(".ui5-carousel-content")
253253
.should("have.attr", "role", "list");
254254

255+
cy.get("#carousel5")
256+
.shadow()
257+
.find(".ui5-carousel-content")
258+
.should("have.attr", "aria-label", "Item Container");
259+
255260
cy.get("#carousel5")
256261
.shadow()
257262
.find(".ui5-carousel-item")

packages/main/src/Carousel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
CAROUSEL_PREVIOUS_ARROW_TEXT,
3434
CAROUSEL_NEXT_ARROW_TEXT,
3535
CAROUSEL_ARIA_ROLE_DESCRIPTION,
36+
CAROUSEL_ARIA_LIST_LABEL,
3637
} from "./generated/i18n/i18n-defaults.js";
3738
import CarouselArrowsPlacement from "./types/CarouselArrowsPlacement.js";
3839
import CarouselPageIndicatorType from "./types/CarouselPageIndicatorType.js";
@@ -977,6 +978,10 @@ class Carousel extends UI5Element {
977978
return Carousel.i18nBundle.getText(CAROUSEL_ARIA_ROLE_DESCRIPTION);
978979
}
979980

981+
get _ariaListLabel() {
982+
return Carousel.i18nBundle.getText(CAROUSEL_ARIA_LIST_LABEL);
983+
}
984+
980985
/**
981986
* Returns only visible (non-hidden) content items.
982987
* Items with the 'hidden' attribute are automatically excluded from carousel navigation.

packages/main/src/CarouselTemplate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function CarouselTemplate(this: Carousel) {
2121
onMouseDown={this._onmousedown}
2222
>
2323
<div class={this.classes.viewport} part="content">
24-
<div role="list" class={this.classes.content} style={{ transform: `translate3d(${this._isRTL ? "" : "-"}${this._currentSlideIndex * (this._itemWidth || 0)}px, 0, 0` }}>
24+
<div role="list" aria-label={this._ariaListLabel} class={this.classes.content} style={{ transform: `translate3d(${this._isRTL ? "" : "-"}${this._currentSlideIndex * (this._itemWidth || 0)}px, 0, 0` }}>
2525
{this.items.map(itemInfo =>
2626
<div
2727
data-sap-focus-ref

packages/main/src/i18n/messagebundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ CAROUSEL_NEXT_ARROW_TEXT=Next Page
115115
#XACT: ARIA announcement for the attribute 'aria-roledescription' of the Carousel component
116116
CAROUSEL_ARIA_ROLE_DESCRIPTION=Carousel
117117

118+
#XACT: ARIA announcement for the aria-label attribute of an element within a Carousel component with a list role
119+
CAROUSEL_ARIA_LIST_LABEL=Item Container
120+
118121
#XFLD: Label of the container holding the colors
119122
COLORPALETTE_CONTAINER_LABEL=Color palette - Predefined colors
120123

0 commit comments

Comments
 (0)