Skip to content

Commit

Permalink
Accessibility/toasts (#780)
Browse files Browse the repository at this point in the history
Make toasts accessibile
  • Loading branch information
snide authored May 5, 2018
1 parent 3ae48ec commit a7c341b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
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-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))

## [`0.0.46`](https://github.com/elastic/eui/tree/v0.0.46)
Expand Down
14 changes: 14 additions & 0 deletions src/components/toast/__snapshots__/global_toast_list.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ exports[`EuiGlobalToastList props toasts is rendered 1`] = `
class="euiGlobalToastList"
>
<div
aria-live="polite"
class="euiToast euiToast--success euiGlobalToastListItem"
data-test-subj="a"
id="a"
>
<p
class="euiScreenReaderOnly"
>
A new notification appears
</p>
<div
aria-label="Notification"
class="euiToastHeader euiToastHeader--withBody"
>
<svg
Expand Down Expand Up @@ -79,11 +86,18 @@ exports[`EuiGlobalToastList props toasts is rendered 1`] = `
</div>
</div>
<div
aria-live="polite"
class="euiToast euiToast--danger euiGlobalToastListItem"
data-test-subj="b"
id="b"
>
<p
class="euiScreenReaderOnly"
>
A new notification appears
</p>
<div
aria-label="Notification"
class="euiToastHeader euiToastHeader--withBody"
>
<svg
Expand Down
49 changes: 49 additions & 0 deletions src/components/toast/__snapshots__/toast.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

exports[`EuiToast Props color danger is rendered 1`] = `
<div
aria-live="polite"
className="euiToast euiToast--danger"
>
<EuiScreenReaderOnly>
<p>
A new notification appears
</p>
</EuiScreenReaderOnly>
<div
aria-label="Notification"
className="euiToastHeader"
>
<span
Expand All @@ -16,9 +23,16 @@ exports[`EuiToast Props color danger is rendered 1`] = `

exports[`EuiToast Props color primary is rendered 1`] = `
<div
aria-live="polite"
className="euiToast euiToast--primary"
>
<EuiScreenReaderOnly>
<p>
A new notification appears
</p>
</EuiScreenReaderOnly>
<div
aria-label="Notification"
className="euiToastHeader"
>
<span
Expand All @@ -30,9 +44,16 @@ exports[`EuiToast Props color primary is rendered 1`] = `

exports[`EuiToast Props color success is rendered 1`] = `
<div
aria-live="polite"
className="euiToast euiToast--success"
>
<EuiScreenReaderOnly>
<p>
A new notification appears
</p>
</EuiScreenReaderOnly>
<div
aria-label="Notification"
className="euiToastHeader"
>
<span
Expand All @@ -44,9 +65,16 @@ exports[`EuiToast Props color success is rendered 1`] = `

exports[`EuiToast Props color warning is rendered 1`] = `
<div
aria-live="polite"
className="euiToast euiToast--warning"
>
<EuiScreenReaderOnly>
<p>
A new notification appears
</p>
</EuiScreenReaderOnly>
<div
aria-label="Notification"
className="euiToastHeader"
>
<span
Expand All @@ -58,9 +86,16 @@ exports[`EuiToast Props color warning is rendered 1`] = `

exports[`EuiToast Props iconType is rendered 1`] = `
<div
aria-live="polite"
className="euiToast"
>
<EuiScreenReaderOnly>
<p>
A new notification appears
</p>
</EuiScreenReaderOnly>
<div
aria-label="Notification"
className="euiToastHeader"
>
<EuiIcon
Expand All @@ -78,9 +113,16 @@ exports[`EuiToast Props iconType is rendered 1`] = `

exports[`EuiToast Props title is rendered 1`] = `
<div
aria-live="polite"
className="euiToast"
>
<EuiScreenReaderOnly>
<p>
A new notification appears
</p>
</EuiScreenReaderOnly>
<div
aria-label="Notification"
className="euiToastHeader"
>
<span
Expand All @@ -95,10 +137,17 @@ exports[`EuiToast Props title is rendered 1`] = `
exports[`EuiToast is rendered 1`] = `
<div
aria-label="aria-label"
aria-live="polite"
class="euiToast testClass1 testClass2"
data-test-subj="test subject string"
>
<p
class="euiScreenReaderOnly"
>
A new notification appears
</p>
<div
aria-label="Notification"
class="euiToastHeader euiToastHeader--withBody"
>
<span
Expand Down
9 changes: 8 additions & 1 deletion src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

import { EuiScreenReaderOnly } from '../accessibility';

import {
ICON_TYPES,
EuiIcon,
Expand Down Expand Up @@ -72,9 +74,14 @@ export const EuiToast = ({ title, color, iconType, onClose, children, className,
return (
<div
className={classes}
aria-live="polite"
{...rest}
>
<div className={headerClasses}>
<EuiScreenReaderOnly>
<p>A new notification appears</p>
</EuiScreenReaderOnly>

<div className={headerClasses} aria-label="Notification">
{headerIcon}

<span className="euiToastHeader__title">
Expand Down

0 comments on commit a7c341b

Please sign in to comment.