Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Handle): add aria-orientation on handles #859

Merged
merged 2 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Handles/Handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const Handle = React.forwardRef((props: HandleProps, ref: React.Ref<HTMLDivEleme
aria-label={getIndex(ariaLabelForHandle, valueIndex)}
aria-labelledby={getIndex(ariaLabelledByForHandle, valueIndex)}
aria-valuetext={getIndex(ariaValueTextFormatterForHandle, valueIndex)?.(value)}
aria-orientation={direction === 'ltr' || direction === 'rtl' ? 'horizontal' : 'vertical'}
yoyo837 marked this conversation as resolved.
Show resolved Hide resolved
{...restProps}
/>
);
Expand Down
20 changes: 20 additions & 0 deletions tests/Range.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,26 @@ describe('Range', () => {
test('touch', (container) => doTouchMove(container, 0, 20, 'rc-slider-track'));
});

it('sets aria-orientation on the handle', () => {
5im0n marked this conversation as resolved.
Show resolved Hide resolved
const { container } = render(<Slider range />);
expect(container.getElementsByClassName('rc-slider-handle')[0]).toHaveAttribute(
'aria-orientation',
'horizontal',
);
});

it('sets aria-orientation on the handle', () => {
5im0n marked this conversation as resolved.
Show resolved Hide resolved
const { container } = render(<Slider range vertical defaultValue={[0, 20]} />);
expect(container.getElementsByClassName('rc-slider-handle')[0]).toHaveAttribute(
'aria-orientation',
'vertical',
);
expect(container.getElementsByClassName('rc-slider-handle')[1]).toHaveAttribute(
'aria-orientation',
'vertical',
);
});

it('sets aria-label on the handles', () => {
const { container } = render(
<Slider range ariaLabelForHandle={['Some Label', 'Some other Label']} />,
Expand Down
6 changes: 6 additions & 0 deletions tests/__snapshots__/Range.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exports[`Range should render Multi-Range with correct DOM structure 1`] = `
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
Expand All @@ -34,6 +35,7 @@ exports[`Range should render Multi-Range with correct DOM structure 1`] = `
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
Expand All @@ -44,6 +46,7 @@ exports[`Range should render Multi-Range with correct DOM structure 1`] = `
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
Expand All @@ -54,6 +57,7 @@ exports[`Range should render Multi-Range with correct DOM structure 1`] = `
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
Expand Down Expand Up @@ -81,6 +85,7 @@ exports[`Range should render Range with correct DOM structure 1`] = `
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
Expand All @@ -91,6 +96,7 @@ exports[`Range should render Range with correct DOM structure 1`] = `
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
Expand Down
1 change: 1 addition & 0 deletions tests/__snapshots__/Slider.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`Slider should render Slider with correct DOM structure 1`] = `
/>
<div
aria-disabled="false"
aria-orientation="horizontal"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="0"
Expand Down