Skip to content

Commit

Permalink
fix: ClearIndicator accessibility improvements (#2222)
Browse files Browse the repository at this point in the history
* fix: select input accessibility inprovements

* chore: add changeset

* chore: changeset update
  • Loading branch information
kark committed Jul 1, 2022
1 parent 7e98481 commit 580ecd5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-cooks-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-uikit/select-utils': patch
---

`<ClearIndicator>` component accessibility improvements
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ describe('in multi mode', () => {
const input = getByLabelText('Fruit');
fireEvent.focus(input);
const deleteButton = getByTitle('Clear');
fireEvent.mouseDown(deleteButton);
fireEvent.click(deleteButton);
expect(onChange).toHaveBeenCalledWith({
persist: expect.any(Function),
target: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ClearIndicator = (props: TClearIndicator) => {
const intl = useIntl();
const {
getStyles,
innerProps: { ref, ...restInnerProps },
innerProps: { ref, onMouseDown, ...restInnerProps },
} = props;
return (
<button
Expand All @@ -37,6 +37,10 @@ const ClearIndicator = (props: TClearIndicator) => {
style={getStyles('clearIndicator', props) as CSSProperties}
title={intl.formatMessage(messages.clearButtonLabel)}
aria-label={intl.formatMessage(messages.clearButtonLabel)}
// overriding the default `aria-hidden` prop value to make the component accessible by keyboard - https://github.com/JedWatson/react-select/issues/4793
aria-hidden={false}
// only onMouseDown and onTouchEnd event handlers are passed by `react-select` to the component by default, which makes it not accessible by keyboard
onClick={onMouseDown}
>
<CloseIcon color="solid" size="medium" />
</button>
Expand Down

1 comment on commit 580ecd5

@vercel
Copy link

@vercel vercel bot commented on 580ecd5 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.