Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

**Bug fixes**

- Added aria-invalid labeling on `EuiFormRow` ([#777](https://github.com/elastic/eui/pull/799))
- Added aria-live labeling for `EuiToasts` ([#777](https://github.com/elastic/eui/pull/777))
- Added aria labeling requirements for `EuiBadge` , as well as a generic prop_type function `requiresAriaLabel` in `utils` to check for it. ([#777](https://github.com/elastic/eui/pull/777))
- Ensure switches’ inputs are still hidden when `[disabled]` ([#778](https://github.com/elastic/eui/pull/778))
Expand Down
5 changes: 5 additions & 0 deletions src-docs/src/views/form_controls/field_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class extends Component {
placeholder="Placeholder text"
value={this.state.value}
onChange={this.onChange}
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -40,6 +41,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
disabled
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -49,6 +51,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
isLoading
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -59,6 +62,7 @@ export default class extends Component {
onChange={this.onChange}
disabled
isLoading
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -68,6 +72,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
readOnly
aria-label="Use aria labels when no actual label is in use"
/>
</Fragment>
);
Expand Down
4 changes: 4 additions & 0 deletions src-docs/src/views/form_controls/field_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class extends Component {
placeholder="Placeholder text"
value={this.state.value}
onChange={this.onChange}
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -39,6 +40,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
disabled
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -48,6 +50,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
isLoading
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -58,6 +61,7 @@ export default class extends Component {
onChange={this.onChange}
isLoading
disabled
aria-label="Use aria labels when no actual label is in use"
/>
</Fragment>
);
Expand Down
5 changes: 5 additions & 0 deletions src-docs/src/views/form_controls/field_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class extends Component {
placeholder="Placeholder text"
value={this.state.value}
onChange={this.onChange}
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -39,6 +40,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
disabled
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -48,6 +50,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
isLoading
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -58,6 +61,7 @@ export default class extends Component {
onChange={this.onChange}
isLoading
disabled
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -67,6 +71,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
readOnly
aria-label="Use aria labels when no actual label is in use"
/>
</Fragment>
);
Expand Down
5 changes: 5 additions & 0 deletions src-docs/src/views/form_controls/field_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class extends Component {
placeholder="Placeholder text"
value={this.state.value}
onChange={this.onChange}
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -39,6 +40,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
disabled
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -48,6 +50,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
isLoading
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -58,6 +61,7 @@ export default class extends Component {
onChange={this.onChange}
isLoading
disabled
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -67,6 +71,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
readOnly
aria-label="Use aria labels when no actual label is in use"
/>
</Fragment>
);
Expand Down
2 changes: 2 additions & 0 deletions src-docs/src/views/form_controls/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class extends Component {
max={200}
value={this.state.value}
onChange={this.onChange}
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -45,6 +46,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
disabled
aria-label="Use aria labels when no actual label is in use"
/>
</Fragment>
);
Expand Down
4 changes: 4 additions & 0 deletions src-docs/src/views/form_controls/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class extends Component {
options={this.options}
value={this.state.value}
onChange={this.onChange}
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -45,6 +46,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
disabled
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -54,6 +56,7 @@ export default class extends Component {
value={this.state.value}
onChange={this.onChange}
isLoading
aria-label="Use aria labels when no actual label is in use"
/>

<EuiSpacer size="m" />
Expand All @@ -64,6 +67,7 @@ export default class extends Component {
onChange={this.onChange}
isLoading
disabled
aria-label="Use aria labels when no actual label is in use"
/>
</Fragment>
);
Expand Down
3 changes: 3 additions & 0 deletions src-docs/src/views/form_controls/text_area.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default class extends Component {
<Fragment>
<EuiTextArea
placeholder="Placeholder text"
aria-label="Use aria labels when no actual label is in use"
value={this.state.value}
onChange={this.onChange}
/>
Expand All @@ -36,6 +37,7 @@ export default class extends Component {

<EuiTextArea
placeholder="Disabled"
aria-label="Use aria labels when no actual label is in use"
value={this.state.value}
onChange={this.onChange}
disabled
Expand All @@ -45,6 +47,7 @@ export default class extends Component {

<EuiTextArea
placeholder="Read-only"
aria-label="Use aria labels when no actual label is in use"
value={this.state.value}
onChange={this.onChange}
readOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,13 @@ exports[`EuiDescribedFormGroup ties together parts for accessibility 1`] = `
id="generated-id-row"
>
<EuiFormLabel
aria-invalid={true}
htmlFor="generated-id"
isFocused={false}
isInvalid={true}
>
<label
aria-invalid={true}
className="euiFormLabel euiFormLabel-isInvalid"
htmlFor="generated-id"
>
Expand All @@ -365,6 +367,7 @@ exports[`EuiDescribedFormGroup ties together parts for accessibility 1`] = `
key="Error one"
>
<div
aria-live="polite"
className="euiFormErrorText euiFormRow__text"
id="generated-id-error-0"
>
Expand All @@ -377,6 +380,7 @@ exports[`EuiDescribedFormGroup ties together parts for accessibility 1`] = `
key="Error two"
>
<div
aria-live="polite"
className="euiFormErrorText euiFormRow__text"
id="generated-id-error-1"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
exports[`EuiFormErrorText is rendered 1`] = `
<div
aria-label="aria-label"
aria-live="polite"
class="euiFormErrorText testClass1 testClass2"
data-test-subj="test subject string"
>
Expand Down
1 change: 1 addition & 0 deletions src/components/form/form_error_text/form_error_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const EuiFormErrorText = ({ children, className, ...rest }) => {
return (
<div
className={classes}
aria-live="polite"
{...rest}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@ exports[`EuiFormRow props error as array is rendered 1`] = `
id="generated-id"
/>
<div
aria-live="polite"
class="euiFormErrorText euiFormRow__text"
id="generated-id-error-0"
>
Error
</div>
<div
aria-live="polite"
class="euiFormErrorText euiFormRow__text"
id="generated-id-error-1"
>
Expand All @@ -209,6 +211,7 @@ exports[`EuiFormRow props error as string is rendered 1`] = `
id="generated-id"
/>
<div
aria-live="polite"
class="euiFormErrorText euiFormRow__text"
id="generated-id-error-0"
>
Expand Down Expand Up @@ -287,6 +290,7 @@ exports[`EuiFormRow props isInvalid is rendered 1`] = `
id="generated-id-row"
>
<label
aria-invalid="true"
class="euiFormLabel euiFormLabel-isInvalid"
for="generated-id"
>
Expand Down
5 changes: 4 additions & 1 deletion src/components/form/form_row/form_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,25 @@ export class EuiFormRow extends Component {
<EuiFormLabel
isFocused={this.state.isFocused}
isInvalid={isInvalid}
aria-invalid={isInvalid}
htmlFor={id}
>
{label}
</EuiFormLabel>
);
}

const optionalProps = {};
const describingIds = [...describedByIds];

if (optionalHelpText) {
describingIds.push(optionalHelpText.props.id);
}

if (optionalErrors) {
optionalErrors.forEach(error => describingIds.push(error.props.id));
}

const optionalProps = {};
if (describingIds.length > 0) {
optionalProps[`aria-describedby`] = describingIds.join(` `);
}
Expand Down