Skip to content

Commit

Permalink
Fix overwritten props for accessibilityLayer (recharts#3920)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
In this case, `props.tabIndex` and `props.role` are not evaluated. so
fixed it.
<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] I have added a storybook story or extended an existing story to
show my changes
- [x] All new and existing tests passed.
  • Loading branch information
mrskiro authored and Gabriel Mercier committed Nov 23, 2023
1 parent 8c63289 commit 406b39c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/chart/generateCategoricalChart.tsx
Expand Up @@ -2318,9 +2318,9 @@ export const generateCategoricalChart = ({

if (this.props.accessibilityLayer) {
// Set tabIndex to 0 by default (can be overwritten)
attrs.tabIndex = 0 ?? this.props.tabIndex;
attrs.tabIndex = this.props.tabIndex ?? 0;
// Set role to img by default (can be overwritten)
attrs.role = 'img' ?? this.props.role;
attrs.role = this.props.role ?? 'img';
attrs.onKeyDown = (e: any) => {
this.accessibilityManager.keyboardEvent(e);
// 'onKeyDown' is not currently a supported prop that can be passed through
Expand Down

0 comments on commit 406b39c

Please sign in to comment.