Skip to content

Commit

Permalink
Added aria-hidden to EuiRangeSlider and EuiRangeTrack (#3423)
Browse files Browse the repository at this point in the history
* Added aria-hidden = true when showInput is true

* Updated snapshots

* Added cl

* Replaced using of showInput with rest

* Updated snapshot

* Removed space

* Refractor conditional operator

* Extend html attributes to range track
  • Loading branch information
ashikmeerankutty authored May 7, 2020
1 parent 6e6b556 commit 916b803
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 6 deletions.
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 `aria-hidden = true` to `EuiRangeSlider` and `EuiRangeTrack` if `showInput = true` ([#3423](https://github.com/elastic/eui/pull/3423))
- Added `testenv` mock for `EuiCode` and `EuiCodeBlock` ([#3405](https://github.com/elastic/eui/pull/3405))

**Bug Fixes**
Expand Down
13 changes: 13 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 @@ -8,6 +8,7 @@ exports[`EuiDualRange allows value prop to accept empty strings 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
Expand Down Expand Up @@ -35,6 +36,7 @@ exports[`EuiDualRange allows value prop to accept numbers 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -89,6 +91,7 @@ exports[`EuiDualRange input props can be applied to min and max inputs 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="true"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -144,6 +147,7 @@ exports[`EuiDualRange is rendered 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -182,6 +186,7 @@ exports[`EuiDualRange props compressed should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -217,6 +222,7 @@ exports[`EuiDualRange props custom ticks should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
style="margin-right:0.6em"
>
Expand Down Expand Up @@ -277,6 +283,7 @@ exports[`EuiDualRange props disabled should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack euiRangeTrack--disabled"
>
<div
Expand Down Expand Up @@ -313,6 +320,7 @@ exports[`EuiDualRange props fullWidth should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -367,6 +375,7 @@ exports[`EuiDualRange props inputs should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="true"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -429,6 +438,7 @@ exports[`EuiDualRange props labels should render 1`] = `
0
</label>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -469,6 +479,7 @@ exports[`EuiDualRange props levels should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -516,6 +527,7 @@ exports[`EuiDualRange props range should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand Down Expand Up @@ -601,6 +613,7 @@ exports[`EuiDualRange props ticks should render 1`] = `
class="euiRange__horizontalSpacer"
/>
<div
aria-hidden="false"
class="euiRangeTrack"
style="margin-right:0.6em"
>
Expand Down
26 changes: 26 additions & 0 deletions src/components/form/range/__snapshots__/range.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ exports[`EuiRange allows value prop to accept a number 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
aria-hidden="false"
class="euiRangeSlider"
id="generated-id"
max="100"
Expand Down Expand Up @@ -38,9 +40,11 @@ exports[`EuiRange allows value prop to accept empty string 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
aria-hidden="false"
class="euiRangeSlider"
id="generated-id"
max="100"
Expand All @@ -61,9 +65,11 @@ exports[`EuiRange is rendered 1`] = `
class="euiRangeWrapper euiRange testClass1 testClass2"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
aria-hidden="false"
aria-label="aria-label"
class="euiRangeSlider"
data-test-subj="test subject string"
Expand All @@ -87,9 +93,11 @@ exports[`EuiRange props compressed should render 1`] = `
class="euiRangeWrapper euiRangeWrapper--compressed euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
aria-hidden="false"
class="euiRangeSlider euiRangeSlider--compressed"
id="generated-id"
max="100"
Expand All @@ -110,6 +118,7 @@ exports[`EuiRange props custom ticks should render 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
style="margin-right:0.6em"
>
Expand Down Expand Up @@ -138,6 +147,7 @@ exports[`EuiRange props custom ticks should render 1`] = `
</button>
</div>
<input
aria-hidden="false"
class="euiRangeSlider euiRangeSlider--hasTicks"
id="generated-id"
max="100"
Expand All @@ -158,9 +168,11 @@ exports[`EuiRange props disabled should render 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack euiRangeTrack--disabled"
>
<input
aria-hidden="false"
class="euiRangeSlider"
disabled=""
id="generated-id"
Expand All @@ -182,9 +194,11 @@ exports[`EuiRange props fullWidth should render 1`] = `
class="euiRangeWrapper euiRangeWrapper--fullWidth euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
aria-hidden="false"
class="euiRangeSlider"
id="generated-id"
max="100"
Expand All @@ -205,9 +219,11 @@ exports[`EuiRange props input should render 1`] = `
class="euiRangeWrapper euiRange testClass1 testClass2"
>
<div
aria-hidden="true"
class="euiRangeTrack"
>
<input
aria-hidden="true"
aria-label="aria-label"
class="euiRangeSlider"
data-test-subj="test subject string"
Expand Down Expand Up @@ -257,9 +273,11 @@ exports[`EuiRange props labels should render 1`] = `
0
</label>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
aria-hidden="false"
class="euiRangeSlider"
id="generated-id"
max="100"
Expand All @@ -285,6 +303,7 @@ exports[`EuiRange props levels should render 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand All @@ -300,6 +319,7 @@ exports[`EuiRange props levels should render 1`] = `
/>
</div>
<input
aria-hidden="false"
class="euiRangeSlider"
id="generated-id"
max="100"
Expand All @@ -320,6 +340,7 @@ exports[`EuiRange props range should render 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<div
Expand All @@ -331,6 +352,7 @@ exports[`EuiRange props range should render 1`] = `
/>
</div>
<input
aria-hidden="false"
class="euiRangeSlider euiRangeSlider--hasRange"
id="generated-id"
max="100"
Expand Down Expand Up @@ -384,6 +406,7 @@ exports[`EuiRange props ticks should render 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
style="margin-right:0.6em"
>
Expand Down Expand Up @@ -447,6 +470,7 @@ exports[`EuiRange props ticks should render 1`] = `
</button>
</div>
<input
aria-hidden="false"
class="euiRangeSlider euiRangeSlider--hasTicks"
id="generated-id"
max="100"
Expand All @@ -467,9 +491,11 @@ exports[`EuiRange props value should render 1`] = `
class="euiRangeWrapper euiRange"
>
<div
aria-hidden="false"
class="euiRangeTrack"
>
<input
aria-hidden="false"
class="euiRangeSlider"
id="generated-id"
max="100"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

exports[`EuiRangeTrack is rendered 1`] = `
<div
class="euiRangeTrack"
aria-label="aria-label"
class="testClass1 testClass2"
data-test-subj="test subject string"
style="margin-right:0.6em"
>
<div
Expand Down
3 changes: 2 additions & 1 deletion src/components/form/range/dual_range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ export class EuiDualRange extends Component<EuiDualRangeProps> {
ticks={ticks}
levels={levels}
onChange={this.handleSliderChange}
value={value}>
value={value}
aria-hidden={showInput === true}>
{showRange && this.isValid && (
<EuiRangeHighlight
compressed={compressed}
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/range/range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ export class EuiRange extends Component<EuiRangeProps> {
ticks={ticks}
levels={levels}
onChange={this.handleOnChange}
value={value}>
value={value}
aria-hidden={showInput === true}>
{showRange && this.isValid && (
<EuiRangeHighlight
compressed={compressed}
Expand Down Expand Up @@ -287,6 +288,7 @@ export class EuiRange extends Component<EuiRangeProps> {
}
onFocus={showInput === true ? undefined : onFocus}
onBlur={showInputOnly ? this.onInputBlur : onBlur}
aria-hidden={showInput === true ? true : false}
{...rest}
/>

Expand Down
8 changes: 5 additions & 3 deletions src/components/form/range/range_track.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import React, { Component, MouseEventHandler } from 'react';
import React, { Component, MouseEventHandler, HTMLAttributes } from 'react';
import classNames from 'classnames';

import range from 'lodash/range';
Expand All @@ -28,7 +28,8 @@ import { EuiRangeTicks, EuiRangeTick } from './range_ticks';

export { LEVEL_COLORS };

export interface EuiRangeTrackProps {
export interface EuiRangeTrackProps
extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
min: number;
max: number;
step?: number;
Expand Down Expand Up @@ -138,6 +139,7 @@ export class EuiRangeTrack extends Component<EuiRangeTrackProps> {
onChange,
value,
compressed,
...rest
} = this.props;

// TODO: Move these to only re-calculate if no-value props have changed
Expand Down Expand Up @@ -167,7 +169,7 @@ export class EuiRangeTrack extends Component<EuiRangeTrackProps> {
});

return (
<div className={trackClasses} style={inputWrapperStyle}>
<div className={trackClasses} style={inputWrapperStyle} {...rest}>
{levels && !!levels.length && (
<EuiRangeLevels
compressed={compressed}
Expand Down

0 comments on commit 916b803

Please sign in to comment.