Skip to content

Commit

Permalink
feat: Announce selected state of chart legend button by screen reader (
Browse files Browse the repository at this point in the history
  • Loading branch information
YueyingLu authored Dec 29, 2022
1 parent fb861ef commit bf862c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,14 @@ describe('Chart legend', () => {
legend.pressLeft();
expect(legend.findFocusedLabel()).toEqual(series[2].label);
});

test('should set aria-pressed as true when the button is selected', () => {
const legend = renderChartLegend();

legend.focus();
legend.pressLeft();
expect(legend.wrapper.find('[role="button"]')!.getElement().getAttribute('aria-pressed')).toBe('true');
legend.pressLeft();
expect(legend.wrapper.find('[role="button"]')!.getElement().getAttribute('aria-pressed')).toBe('false');
});
});
1 change: 1 addition & 0 deletions src/internal/components/chart-legend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function ChartLegend<T>({
{...focusVisible}
role="button"
key={index}
aria-pressed={isHighlighted}
className={clsx(styles.marker, {
[styles['marker--dimmed']]: isDimmed,
[styles['marker--highlighted']]: isHighlighted,
Expand Down

0 comments on commit bf862c9

Please sign in to comment.