Skip to content

Commit ea4a1ac

Browse files
Fixing the spaces header aria-controls a11y issue (#54512)
* Fixing the spaces header aria-controls a11y issue * Updating snapshots Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 641c670 commit ea4a1ac

File tree

6 files changed

+13
-2
lines changed

6 files changed

+13
-2
lines changed

x-pack/legacy/plugins/spaces/public/nav_control/__snapshots__/nav_control_popover.test.tsx.snap

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/spaces/public/nav_control/components/__snapshots__/spaces_description.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('SpacesDescription', () => {
1313
expect(
1414
shallow(
1515
<SpacesDescription
16+
id={'foo'}
1617
capabilities={{
1718
navLinks: {},
1819
management: {},

x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_description.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import { ManageSpacesButton } from './manage_spaces_button';
1111
import { getSpacesFeatureDescription } from '../../constants';
1212

1313
interface Props {
14+
id: string;
1415
onManageSpacesClick: () => void;
1516
capabilities: Capabilities;
1617
}
1718

1819
export const SpacesDescription: FC<Props> = (props: Props) => {
1920
const panelProps = {
21+
id: props.id,
2022
className: 'spcDescription',
2123
title: 'Spaces',
2224
};

x-pack/legacy/plugins/spaces/public/nav_control/components/spaces_menu.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ManageSpacesButton } from './manage_spaces_button';
2020
import { SpaceAvatar } from '../../space_avatar';
2121

2222
interface Props {
23+
id: string;
2324
spaces: Space[];
2425
isLoading: boolean;
2526
onSelectSpace: (space: Space) => void;
@@ -48,6 +49,7 @@ class SpacesMenuUI extends Component<Props, State> {
4849
: this.getVisibleSpaces(searchTerm).map(this.renderSpaceMenuItem);
4950

5051
const panelProps = {
52+
id: this.props.id,
5153
className: 'spcMenu',
5254
title: intl.formatMessage({
5355
id: 'xpack.spaces.navControl.spacesMenu.changeCurrentSpaceTitle',

x-pack/legacy/plugins/spaces/public/nav_control/nav_control_popover.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ interface State {
3232
spaces: Space[];
3333
}
3434

35+
const popoutContentId = 'headerSpacesMenuContent';
36+
3537
export class NavControlPopover extends Component<Props, State> {
3638
private activeSpace$?: Subscription;
3739

@@ -71,13 +73,15 @@ export class NavControlPopover extends Component<Props, State> {
7173
if (!this.state.loading && this.state.spaces.length < 2) {
7274
element = (
7375
<SpacesDescription
76+
id={popoutContentId}
7477
onManageSpacesClick={this.toggleSpaceSelector}
7578
capabilities={this.props.capabilities}
7679
/>
7780
);
7881
} else {
7982
element = (
8083
<SpacesMenu
84+
id={popoutContentId}
8185
spaces={this.state.spaces}
8286
isLoading={this.state.loading}
8387
onSelectSpace={this.onSelectSpace}
@@ -140,7 +144,7 @@ export class NavControlPopover extends Component<Props, State> {
140144
private getButton = (linkIcon: JSX.Element, linkTitle: string) => {
141145
return (
142146
<EuiHeaderSectionItemButton
143-
aria-controls="headerSpacesMenuList"
147+
aria-controls={popoutContentId}
144148
aria-expanded={this.state.showSpaceSelector}
145149
aria-haspopup="true"
146150
aria-label={linkTitle}

0 commit comments

Comments
 (0)