diff --git a/CHANGELOG.md b/CHANGELOG.md
index 777c40c70cc..5a82de0a27b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,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))
- Fixed a bug in `EuiDataGrid` causing the first cell to autofocus if interactive ([#2872](https://github.com/elastic/eui/pull/2872))
**Breaking changes**
diff --git a/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap b/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap
index 2cc54e4350b..8ec6d9cb6ee 100644
--- a/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap
+++ b/src/components/bottom_bar/__snapshots__/bottom_bar.test.tsx.snap
@@ -2,74 +2,107 @@
exports[`EuiBottomBar is rendered 1`] = `
Array [
-
- There is a new menu opening with page level controls at the end of the document.
-
,
-
+
+ Page level controls
+
Content
-
,
+ ,
+
+ There is a new region landmark with page level controls at the end of the document.
+
,
]
`;
exports[`EuiBottomBar props paddingSize l is rendered 1`] = `
Array [
+
+
+ Page level controls
+
+ ,
- 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.
,
- ,
]
`;
exports[`EuiBottomBar props paddingSize m is rendered 1`] = `
Array [
+
+
+ Page level controls
+
+ ,
- 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.
- 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.
,
- ,
]
`;
exports[`EuiBottomBar props paddingSize s is rendered 1`] = `
Array [
+
+
+ Page level controls
+
+ ,
- 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.
,
- ,
]
`;
diff --git a/src/components/bottom_bar/bottom_bar.tsx b/src/components/bottom_bar/bottom_bar.tsx
index 67d633ac67b..e8e5ecfdd31 100644
--- a/src/components/bottom_bar/bottom_bar.tsx
+++ b/src/components/bottom_bar/bottom_bar.tsx
@@ -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';
@@ -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".
+ */
+ landmarkHeading?: string;
}
export class EuiBottomBar extends Component {
- private bar: HTMLDivElement | null = null;
+ private bar: HTMLElement | null = null;
componentDidMount() {
const height = this.bar ? this.bar.clientHeight : -1;
@@ -42,7 +46,7 @@ export class EuiBottomBar extends Component {
}
componentWillUnmount() {
- document.body.style.paddingBottom = null;
+ document.body.style.paddingBottom = '';
if (this.props.bodyClassName) {
document.body.classList.remove(this.props.bodyClassName);
}
@@ -54,6 +58,7 @@ export class EuiBottomBar extends Component {
className,
paddingSize = 'm',
bodyClassName,
+ landmarkHeading,
...rest
} = this.props;
@@ -65,22 +70,46 @@ export class EuiBottomBar extends Component {
return (
+
+ {(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
+ {
+ this.bar = node;
+ }}
+ {...rest}>
+
+
+ There is a new region landmark with page level controls at the end of the document.
+
+
+
@@ -396,10 +439,16 @@ exports[`EuiControlBar props maxHeight is rendered 1`] = `
-
+ There is a new region landmark with page level controls at the end of the document.
+
+
+
@@ -657,10 +738,16 @@ exports[`EuiControlBar props mobile is rendered 1`] = `
-
+
+ Page level controls
+
@@ -724,134 +811,166 @@ exports[`EuiControlBar props mobile is rendered 1`] = `
Flight 815
-
+
+
+ There is a new region landmark 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.
+
+
+
@@ -914,130 +1033,143 @@ exports[`EuiControlBar props position is rendered 1`] = `
showOnMobile={false}
size="l"
>
-
+ There is a new region landmark with page level controls at the end of the document.
+
+
+
@@ -1363,10 +1533,16 @@ exports[`EuiControlBar props showContent is rendered 1`] = `
-
+
+ There is a new region landmark with page level controls at the end of the document.
+
+
+
@@ -1634,10 +1842,16 @@ exports[`EuiControlBar props size is rendered 1`] = `
-
+
+ {(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
+
+
+