File tree Expand file tree Collapse file tree 4 files changed +38
-2
lines changed
Expand file tree Collapse file tree 4 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff 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" ;
3132import CarouselArrowsPlacement from "./types/CarouselArrowsPlacement.js" ;
3233import 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
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change @@ -103,6 +103,9 @@ CAROUSEL_PREVIOUS_ARROW_TEXT=Previous Page
103103# Carousel Next Page text
104104CAROUSEL_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
107110COLORPALETTE_CONTAINER_LABEL =Color palette - Predefined colors
108111
You can’t perform that action at this time.
0 commit comments