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

EuiDualRange: Add possibility to set input properties for min and max inputs #2738

Merged
merged 11 commits into from
Jan 9, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added possibility to set `aria-label` for both `min` and `max` inputs of `EuiDualRange` ([#2738](https://github.com/elastic/eui/pull/2738))
- Fixed bug in `EuiCard` where button text was not properly aligned ([#2741](https://github.com/elastic/eui/pull/2741))
- Converted `EuiRange` to TypeScript ([#2732](https://github.com/elastic/eui/pull/2732))
- Converted `EuiDualRange` to TypeScript ([#2732](https://github.com/elastic/eui/pull/2732))
Expand Down
2 changes: 2 additions & 0 deletions src-docs/src/views/range/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default class extends Component {
value={this.state.dualValue}
onChange={this.onDualChange}
showInput
minInputProps={{ 'aria-label': 'Min value' }}
maxInputProps={{ 'aria-label': 'Max value' }}
/>
</Fragment>
);
Expand Down
296 changes: 296 additions & 0 deletions src/components/form/range/__snapshots__/dual_range.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,299 @@ exports[`EuiDualRange props ticks should render 1`] = `
/>
</div>
`;

exports[`EuiDualRange aria labels should be set for both min and max inputs 1`] = `
<div
class="euiRangeWrapper euiDualRange"
>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
aria-label="Min value"
class="euiFieldNumber euiRangeInput euiRangeInput--min"
max="8"
min="1"
name="name-minValue"
step="1"
style="width:3.6em"
type="number"
value="1"
/>
</div>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiRangeTrack"
>
<div
class="euiRangeHighlight"
>
<div
class="euiRangeHighlight__progress"
style="margin-left:0%;width:77.77777777777779%"
/>
</div>
<input
aria-hidden="true"
class="euiRangeSlider euiRangeSlider--hasRange euiDualRange__slider"
id="id"
max="10"
min="1"
name="name"
step="1"
tabindex="-1"
type="range"
/>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
aria-label="Max value"
class="euiFieldNumber euiRangeInput euiRangeInput--max"
max="10"
min="1"
name="name-maxValue"
step="1"
style="width:3.6em"
type="number"
value="8"
/>
</div>
</div>
</div>
`;

exports[`EuiDualRange aria labels should be set only for the min input 1`] = `
<div
class="euiRangeWrapper euiDualRange"
>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
aria-label="Min value"
class="euiFieldNumber euiRangeInput euiRangeInput--min"
max="8"
min="1"
name="name-minValue"
step="1"
style="width:3.6em"
type="number"
value="1"
/>
</div>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiRangeTrack"
>
<div
class="euiRangeHighlight"
>
<div
class="euiRangeHighlight__progress"
style="margin-left:0%;width:77.77777777777779%"
/>
</div>
<input
aria-hidden="true"
class="euiRangeSlider euiRangeSlider--hasRange euiDualRange__slider"
id="id"
max="10"
min="1"
name="name"
step="1"
tabindex="-1"
type="range"
/>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
class="euiFieldNumber euiRangeInput euiRangeInput--max"
max="10"
min="1"
name="name-maxValue"
step="1"
style="width:3.6em"
type="number"
value="8"
/>
</div>
</div>
</div>
`;

exports[`EuiDualRange aria labels should be set only for the max input 1`] = `
<div
class="euiRangeWrapper euiDualRange"
>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
class="euiFieldNumber euiRangeInput euiRangeInput--min"
max="8"
min="1"
name="name-minValue"
step="1"
style="width:3.6em"
type="number"
value="1"
/>
</div>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiRangeTrack"
>
<div
class="euiRangeHighlight"
>
<div
class="euiRangeHighlight__progress"
style="margin-left:0%;width:77.77777777777779%"
/>
</div>
<input
aria-hidden="true"
class="euiRangeSlider euiRangeSlider--hasRange euiDualRange__slider"
id="id"
max="10"
min="1"
name="name"
step="1"
tabindex="-1"
type="range"
/>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
aria-label="Max value"
class="euiFieldNumber euiRangeInput euiRangeInput--max"
max="10"
min="1"
name="name-maxValue"
step="1"
style="width:3.6em"
type="number"
value="8"
/>
</div>
</div>
</div>
`;

exports[`EuiDualRange aria labels defined for the whole component should be set only for both min and max input 1`] = `
<div
class="euiRangeWrapper euiDualRange"
>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
aria-label="aria-label"
class="euiFieldNumber euiRangeInput euiRangeInput--min"
max="8"
min="1"
name="name-minValue"
step="1"
style="width:3.6em"
type="number"
value="1"
/>
</div>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiRangeTrack"
>
<div
class="euiRangeHighlight"
>
<div
class="euiRangeHighlight__progress"
style="margin-left:0%;width:77.77777777777779%"
/>
</div>
<input
aria-hidden="true"
aria-label="aria-label"
class="euiRangeSlider euiRangeSlider--hasRange euiDualRange__slider"
id="id"
max="10"
min="1"
name="name"
step="1"
tabindex="-1"
type="range"
/>
</div>
<div
class="euiRange__horizontalSpacer"
/>
<div
class="euiFormControlLayout"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<input
aria-label="aria-label"
class="euiFieldNumber euiRangeInput euiRangeInput--max"
max="10"
min="1"
name="name-maxValue"
step="1"
style="width:3.6em"
type="number"
value="8"
/>
</div>
</div>
</div>
`;

71 changes: 71 additions & 0 deletions src/components/form/range/dual_range.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,75 @@ describe('EuiDualRange', () => {

expect(component).toMatchSnapshot();
});

describe('aria labels', () => {
test('should be set for both min and max inputs', () => {
const component = render(
<EuiDualRange
name="name"
id="id"
min={1}
max={10}
value={['1', '8']}
onChange={() => {}}
showInput
minInputProps={{ 'aria-label': 'Min value' }}
maxInputProps={{ 'aria-label': 'Max value' }}
/>
);

expect(component).toMatchSnapshot();
});

test('should be set only for the min input', () => {
const component = render(
<EuiDualRange
name="name"
id="id"
min={1}
max={10}
value={['1', '8']}
onChange={() => {}}
showInput
minInputProps={{ 'aria-label': 'Min value' }}
/>
);

expect(component).toMatchSnapshot();
});

test('should be set only for the max input', () => {
const component = render(
<EuiDualRange
name="name"
id="id"
min={1}
max={10}
value={['1', '8']}
onChange={() => {}}
showInput
maxInputProps={{ 'aria-label': 'Max value' }}
/>
);

expect(component).toMatchSnapshot();
});

test('defined for the whole component should be set only for both min and max input', () => {
const component = render(
<EuiDualRange
name="name"
id="id"
min={1}
max={10}
value={['1', '8']}
onChange={() => {}}
showInput
aria-label="aria-label"
/>
);

expect(component).toMatchSnapshot();
});
});
});
Loading