Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -8,6 +8,7 @@
**Bug fixes**

- Fixed building dev & docs on Windows ([#2847](https://github.com/elastic/eui/pull/2847))
- Fixed screen reader discovery issues with `EuiBottomBar` and `EuiControlBar` ([#2861](https://github.com/elastic/eui/pull/2861))

## [`19.0.0`](https://github.com/elastic/eui/tree/v19.0.0)

Expand Down
81 changes: 57 additions & 24 deletions src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,107 @@

exports[`EuiBottomBar is rendered 1`] = `
Array [
<p
aria-live="assertive"
class="euiScreenReaderOnly"
>
There is a new menu opening with page level controls at the end of the document.
</p>,
<div
<section
aria-label="aria-label"
class="euiBottomBar euiBottomBar--paddingMedium testClass1 testClass2"
data-test-subj="test subject string"
>
<h2
class="euiScreenReaderOnly"
>
Page level controls
</h2>
Content
</div>,
</section>,
<p
aria-live="assertive"
class="euiScreenReaderOnly"
>
There is a new region landmark with page level controls at the end of the document.
</p>,
]
`;

exports[`EuiBottomBar props paddingSize l is rendered 1`] = `
Array [
<section
aria-label="Page level controls"
class="euiBottomBar euiBottomBar--paddingLarge"
>
<h2
class="euiScreenReaderOnly"
>
Page level controls
</h2>
</section>,
<p
aria-live="assertive"
class="euiScreenReaderOnly"
>
There is a new menu opening with page level controls at the end of the document.
There is a new region landmark with page level controls at the end of the document.
</p>,
<div
class="euiBottomBar euiBottomBar--paddingLarge"
/>,
]
`;

exports[`EuiBottomBar props paddingSize m is rendered 1`] = `
Array [
<section
aria-label="Page level controls"
class="euiBottomBar euiBottomBar--paddingMedium"
>
<h2
class="euiScreenReaderOnly"
>
Page level controls
</h2>
</section>,
<p
aria-live="assertive"
class="euiScreenReaderOnly"
>
There is a new menu opening with page level controls at the end of the document.
There is a new region landmark with page level controls at the end of the document.
</p>,
<div
class="euiBottomBar euiBottomBar--paddingMedium"
/>,
]
`;

exports[`EuiBottomBar props paddingSize none is rendered 1`] = `
Array [
<section
aria-label="Page level controls"
class="euiBottomBar"
>
<h2
class="euiScreenReaderOnly"
>
Page level controls
</h2>
</section>,
<p
aria-live="assertive"
class="euiScreenReaderOnly"
>
There is a new menu opening with page level controls at the end of the document.
There is a new region landmark with page level controls at the end of the document.
</p>,
<div
class="euiBottomBar"
/>,
]
`;

exports[`EuiBottomBar props paddingSize s is rendered 1`] = `
Array [
<section
aria-label="Page level controls"
class="euiBottomBar euiBottomBar--paddingSmall"
>
<h2
class="euiScreenReaderOnly"
>
Page level controls
</h2>
</section>,
<p
aria-live="assertive"
class="euiScreenReaderOnly"
>
There is a new menu opening with page level controls at the end of the document.
There is a new region landmark with page level controls at the end of the document.
</p>,
<div
class="euiBottomBar euiBottomBar--paddingSmall"
/>,
]
`;
61 changes: 43 additions & 18 deletions src/components/bottom_bar/bottom_bar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { Component } from 'react';
import classNames from 'classnames';

import { CommonProps } from '../common';
import { EuiPortal } from '../portal';
import React, { Component } from 'react';
import { EuiScreenReaderOnly } from '../accessibility';
import { CommonProps } from '../common';
import { EuiI18n } from '../i18n';
import { EuiPortal } from '../portal';

type BottomBarPaddingSize = 'none' | 's' | 'm' | 'l';

Expand All @@ -28,10 +27,15 @@ interface Props extends CommonProps {
* Padding applied to the bar
*/
paddingSize?: BottomBarPaddingSize;

/**
* Customize the screen reader heading that helps users find this control. Default is "Page level controls".
*/
title?: string;
Comment thread
myasonik marked this conversation as resolved.
Outdated
}

export class EuiBottomBar extends Component<Props> {
private bar: HTMLDivElement | null = null;
private bar: HTMLElement | null = null;

componentDidMount() {
const height = this.bar ? this.bar.clientHeight : -1;
Expand All @@ -42,7 +46,7 @@ export class EuiBottomBar extends Component<Props> {
}

componentWillUnmount() {
document.body.style.paddingBottom = null;
document.body.style.paddingBottom = '';
if (this.props.bodyClassName) {
document.body.classList.remove(this.props.bodyClassName);
}
Expand All @@ -54,6 +58,7 @@ export class EuiBottomBar extends Component<Props> {
className,
paddingSize = 'm',
bodyClassName,
title,
...rest
} = this.props;

Expand All @@ -65,22 +70,42 @@ export class EuiBottomBar extends Component<Props> {

return (
<EuiPortal>
<EuiI18n
token="euiBottomBar.screenReaderHeading"
default="Page level controls">
{(screenReaderHeading: string) => (
// Though it would be better to use aria-labelledby than aria-label and not repeat the same string twice
// A bug in voiceover won't list some landmarks in the rotor without an aria-label
Comment thread
cchaos marked this conversation as resolved.
<section
aria-label={title ? title : screenReaderHeading}
className={classes}
ref={node => {
this.bar = node;
}}
{...rest}>
Comment thread
cchaos marked this conversation as resolved.
<EuiScreenReaderOnly>
<h2>{title ? title : screenReaderHeading}</h2>
Comment thread
cchaos marked this conversation as resolved.
Outdated
</EuiScreenReaderOnly>
{children}
</section>
)}
</EuiI18n>
<EuiScreenReaderOnly>
<p aria-live="assertive">
<EuiI18n
token="euiBottomBar.screenReaderAnnouncement"
default="There is a new menu opening with page level controls at the end of the document."
/>
{title ? (
<EuiI18n
token="euiBottomBar.screenReaderAnnouncement"
default="There is a new region landmark called {title} with page level controls at the end of the document."
values={{ title }}
/>
) : (
<EuiI18n
token="euiBottomBar.screenReaderAnnouncement"
Comment thread
myasonik marked this conversation as resolved.
default="There is a new region landmark with page level controls at the end of the document."
/>
)}
</p>
</EuiScreenReaderOnly>
<div
className={classes}
ref={node => {
this.bar = node;
}}
{...rest}>
{children}
</div>
</EuiPortal>
);
}
Expand Down
Loading