Skip to content

Commit 13dbc9d

Browse files
authored
Merge pull request #1138 from WonSong/wosong/carousel
Adds aria-label options for Carousel buttons
2 parents d74c7ff + 918d333 commit 13dbc9d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/controls/carousel/Carousel.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export class Carousel extends React.Component<ICarouselProps, ICarouselState> {
6666
loadingComponentContainerStyles,
6767
prevButtonIconName = 'ChevronLeft',
6868
nextButtonIconName = 'ChevronRight',
69+
prevButtonAriaLabel = 'Previous item',
70+
nextButtonAriaLabel = 'Next item',
6971
loadingComponent = <Spinner />,
7072
pauseOnHover,
7173
interval,
@@ -88,7 +90,7 @@ export class Carousel extends React.Component<ICarouselProps, ICarouselState> {
8890
onClick={() => { if (!prevButtonDisabled) { this.onCarouselButtonClicked(false); } }} >
8991
<IconButton
9092
className={this.getMergedStyles(this.getButtonStyles(false), prevButtonStyles)}
91-
iconProps={{ iconName: prevButtonIconName }}
93+
iconProps={{ iconName: prevButtonIconName, ariaLabel: prevButtonAriaLabel }}
9294
disabled={prevButtonDisabled}
9395
onClick={() => { this.onCarouselButtonClicked(false); }} />
9496
</div>
@@ -115,7 +117,7 @@ export class Carousel extends React.Component<ICarouselProps, ICarouselState> {
115117
onClick={() => { if (!nextButtonDisabled) { this.onCarouselButtonClicked(true); } }}>
116118
<IconButton
117119
className={this.getMergedStyles(this.getButtonStyles(true), nextButtonStyles)}
118-
iconProps={{ iconName: nextButtonIconName }}
120+
iconProps={{ iconName: nextButtonIconName, ariaLabel: nextButtonAriaLabel }}
119121
disabled={nextButtonDisabled}
120122
onClick={() => { this.onCarouselButtonClicked(true); }} />
121123
</div>

src/controls/carousel/ICarouselProps.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ export interface ICarouselProps {
122122
* Name of the icon to be used for NextItem button. Default 'ChevronRight'.
123123
*/
124124
nextButtonIconName?: string;
125+
/**
126+
* Aria label of the PreviousItem button. Default 'Previous item'.
127+
*/
128+
prevButtonAriaLabel?: string;
129+
130+
/**
131+
* Aria label of the NextItem button. Default 'Next item'.
132+
*/
133+
nextButtonAriaLabel?: string;
125134
/**
126135
* Triggers parent control to provide new element to be displayed. After the method is executed, carousel control switches to processing mode and loadingComponent is displayed.
127136
*/

0 commit comments

Comments
 (0)