Skip to content

Commit

Permalink
gh-545: Remove tabindex for non-interactive div
Browse files Browse the repository at this point in the history
  • Loading branch information
greenyouse committed Apr 2, 2021
1 parent d78aa78 commit e1ba29b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 8 additions & 0 deletions src/__tests__/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ describe('Slider', function() {
componentInstance.navigateWithKeyboard
);
});

it('should not set a tabIndex on the carousel-root', () => {
expect(component.find('.carousel-root[tabIndex=0]').length).toBe(0);
});
});

describe('when useKeyboardArrows is true', () => {
Expand Down Expand Up @@ -343,6 +347,10 @@ describe('Slider', function() {
componentInstance.navigateWithKeyboard
);
});

it('should set a tabIndex on the carousel-root', () => {
expect(component.find('.carousel-root[tabIndex=0]').length).toBe(1);
});
});
});

Expand Down
11 changes: 0 additions & 11 deletions src/__tests__/__snapshots__/Carousel.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Array [
exports[`Slider Snapshots center mode 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -444,7 +443,6 @@ exports[`Slider Snapshots center mode 1`] = `
exports[`Slider Snapshots custom class name 1`] = `
<div
className="carousel-root my-custom-carousel"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -795,7 +793,6 @@ exports[`Slider Snapshots custom class name 1`] = `
exports[`Slider Snapshots custom width 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -1146,7 +1143,6 @@ exports[`Slider Snapshots custom width 1`] = `
exports[`Slider Snapshots default 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -1497,7 +1493,6 @@ exports[`Slider Snapshots default 1`] = `
exports[`Slider Snapshots infinite loop 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -1866,7 +1861,6 @@ exports[`Slider Snapshots infinite loop 1`] = `
exports[`Slider Snapshots no arrows 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -2219,7 +2213,6 @@ exports[`Slider Snapshots no children at mount 1`] = `null`;
exports[`Slider Snapshots no indicators 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -2503,7 +2496,6 @@ exports[`Slider Snapshots no indicators 1`] = `
exports[`Slider Snapshots no indicators 2`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -2849,7 +2841,6 @@ exports[`Slider Snapshots no indicators 2`] = `
exports[`Slider Snapshots no thumbs 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -3038,7 +3029,6 @@ exports[`Slider Snapshots no thumbs 1`] = `
exports[`Slider Snapshots swipeable false 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down Expand Up @@ -3386,7 +3376,6 @@ exports[`Slider Snapshots swipeable false 1`] = `
exports[`Slider Snapshots vertical axis 1`] = `
<div
className="carousel-root"
tabIndex={0}
>
<div
className="carousel carousel-slider"
Expand Down
6 changes: 5 additions & 1 deletion src/components/Carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,11 @@ export default class Carousel extends React.Component<CarouselProps, CarouselSta
containerStyles.height = this.state.itemSize;
}
return (
<div className={klass.ROOT(this.props.className)} ref={this.setCarouselWrapperRef} tabIndex={0}>
<div
className={klass.ROOT(this.props.className)}
ref={this.setCarouselWrapperRef}
tabIndex={this.props.useKeyboardArrows ? 0 : undefined}
>
<div className={klass.CAROUSEL(true)} style={{ width: this.props.width }}>
{this.renderControls()}
{this.props.renderArrowPrev(this.onClickPrev, hasPrev, this.props.labels.leftArrow)}
Expand Down

0 comments on commit e1ba29b

Please sign in to comment.