Skip to content

Commit

Permalink
fix(a11y): Fix a11y issues reported by Lighthouse
Browse files Browse the repository at this point in the history
- Fixed the accessibility issue of the `aria-controls`s' relationship between the slider and its controls ([reference](https://dequeuniversity.com/rules/axe/4.7/aria-valid-attr-value)).
- Fixed the `tabindex` accessibility issue of the dots controls ([reference](https://dequeuniversity.com/rules/axe/4.7/tabindex)).
  • Loading branch information
joaocongio authored Nov 6, 2023
1 parent 3f56ff4 commit 0871ed4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Fixed the accessibility issue of the `aria-controls`s' relationship between the slider and its controls ([reference](https://dequeuniversity.com/rules/axe/4.7/aria-valid-attr-value)).
- Fixed the `tabindex` accessibility issue of the dots controls ([reference](https://dequeuniversity.com/rules/axe/4.7/tabindex)).

## [0.24.3] - 2023-05-08

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion react/components/PaginationDots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const PaginationDots: FC<Props> = ({ controls, totalItems, infinite }) => {
width: `${DOTS_DEFAULT_SIZE}rem`,
}}
key={index}
tabIndex={index}
tabIndex={isActive ? 0 : -1}
onKeyDown={event => handleDotClick(event, index)}
onClick={event => handleDotClick(event, index)}
role="button"
Expand Down
5 changes: 4 additions & 1 deletion react/components/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const Slider: FC<Props> = ({
const controls = `${label
.toLowerCase()
.trim()
.replace(/ /g, '-')}-items`
.replace(/ /g, '-')}-items-${Math.random()
.toString(36)
.substring(2, 9)}`

const shouldShowArrows = Boolean(
(showNavigationArrows === 'always' ||
Expand Down Expand Up @@ -98,6 +100,7 @@ const Slider: FC<Props> = ({
onTouchEnd={touchEndHandler}
onTouchMove={touchMoveHandler}
aria-label={label}
id={controls}
style={{
WebkitOverflowScrolling: !shouldUsePagination ? 'touch' : undefined,
paddingLeft: fullWidth ? undefined : arrowSize * 2,
Expand Down

0 comments on commit 0871ed4

Please sign in to comment.