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

Added role='dialog' to EuiFlyout and documented correct way to make it announce itself with aria attributes #916

Merged
merged 2 commits into from
Jun 11, 2018
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `0.0.52`.
**Bug fixes**

- Added `role="dialog"` to `EuiFlyout` to improve screen reader accessibility ([#916](https://github.com/elastic/eui/pull/916))

## [`0.0.52`](https://github.com/elastic/eui/tree/v0.0.52)

Expand Down
12 changes: 10 additions & 2 deletions src-docs/src/views/flyout/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,23 @@ export class Flyout extends Component {
}

render() {

let flyout;

if (this.state.isFlyoutVisible) {
flyout = (
<EuiFlyout
onClose={this.closeFlyout}
aria-labelledby="flyoutTitle"
>
<EuiFlyoutBody>
<EuiText>
<p>You can use ESC to close this panel, but we could also pass in a close button like so.</p>
<h3 id="flyoutTitle">
A flyout
</h3>

<p>
You can use ESC to close this panel, but we could also pass in a close button like so.
</p>

<EuiButton
iconType="cross"
Expand All @@ -59,6 +66,7 @@ export class Flyout extends Component {
</EuiFlyout>
);
}

return (
<div>
<EuiButton onClick={this.showFlyout}>
Expand Down
4 changes: 3 additions & 1 deletion src-docs/src/views/flyout/flyout_complicated.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ export class FlyoutComplicated extends Component {
flyout = (
<EuiFlyout
onClose={this.closeFlyout}
aria-labelledby="flyoutComplicatedTitle"
>
<EuiFlyoutHeader>
<EuiTitle>
<h2>
<h2 id="flyoutComplicatedTitle">
Flyout header
</h2>
</EuiTitle>
Expand Down Expand Up @@ -184,6 +185,7 @@ export class FlyoutComplicated extends Component {
</EuiFlyout>
);
}

return (
<div>
<EuiButton onClick={this.showFlyout}>
Expand Down
6 changes: 6 additions & 0 deletions src-docs/src/views/flyout/flyout_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const FlyoutExample = {
from the right side of the screen. It should be used any time you
need to perform quick, individual actions to a larger page or list.
</p>

<ul>
<li>
<EuiCode>size</EuiCode> accepts <EuiCode>s / m / l</EuiCode> and
Expand All @@ -52,6 +53,11 @@ export const FlyoutExample = {
to within the flyout. It is off by default.
</li>
</ul>

<p>
Notice how these examples use <EuiCode>aria-labelledby</EuiCode> and <EuiCode>aria-describedby</EuiCode> to
announce the flyout to screen readers when the user opens it.
</p>
</div>
),
props: { EuiFlyout },
Expand Down
9 changes: 8 additions & 1 deletion src-docs/src/views/flyout/flyout_size.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ export class FlyoutSize extends Component {
ownFocus
onClose={this.closeFlyout}
size="s"
aria-labelledby="flyoutSizeTitle"
>
<EuiFlyoutBody>
<EuiText>
<p>You can use ESC to close this panel, but we could also pass in a close button like so.</p>
<h3 id="flyoutSizeTitle">
A flyout
</h3>

<p>
You can use ESC to close this panel, but we could also pass in a close button like so.
</p>

<EuiButton
iconType="cross"
Expand Down
1 change: 1 addition & 0 deletions src/components/flyout/__snapshots__/flyout.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`EuiFlyout is rendered 1`] = `
aria-label="aria-label"
class="euiFlyout euiFlyout--medium testClass1 testClass2"
data-test-subj="test subject string"
role="dialog"
tabindex="0"
/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/components/flyout/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class EuiFlyout extends Component {

const flyoutContent = (
<div
role="dialog"
ref={node => { this.flyout = node; }}
className={classes}
tabIndex={0}
Expand All @@ -68,6 +69,8 @@ export class EuiFlyout extends Component {
return (
<span>
{optionalOverlay}
{/* Trap focus even when ownFocus={false}, otherwise closing the flyout won't return focus
to the originating button */}
<FocusTrap
focusTrapOptions={{
fallbackFocus: () => this.flyout,
Expand Down