Skip to content

Commit

Permalink
Fixing the spaces header aria-controls a11y issue (#54512)
Browse files Browse the repository at this point in the history
* Fixing the spaces header aria-controls a11y issue

* Updating snapshots

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
kobelb and elasticmachine authored Jan 13, 2020
1 parent 641c670 commit ea4a1ac
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('SpacesDescription', () => {
expect(
shallow(
<SpacesDescription
id={'foo'}
capabilities={{
navLinks: {},
management: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import { ManageSpacesButton } from './manage_spaces_button';
import { getSpacesFeatureDescription } from '../../constants';

interface Props {
id: string;
onManageSpacesClick: () => void;
capabilities: Capabilities;
}

export const SpacesDescription: FC<Props> = (props: Props) => {
const panelProps = {
id: props.id,
className: 'spcDescription',
title: 'Spaces',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ManageSpacesButton } from './manage_spaces_button';
import { SpaceAvatar } from '../../space_avatar';

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

const panelProps = {
id: this.props.id,
className: 'spcMenu',
title: intl.formatMessage({
id: 'xpack.spaces.navControl.spacesMenu.changeCurrentSpaceTitle',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ interface State {
spaces: Space[];
}

const popoutContentId = 'headerSpacesMenuContent';

export class NavControlPopover extends Component<Props, State> {
private activeSpace$?: Subscription;

Expand Down Expand Up @@ -71,13 +73,15 @@ export class NavControlPopover extends Component<Props, State> {
if (!this.state.loading && this.state.spaces.length < 2) {
element = (
<SpacesDescription
id={popoutContentId}
onManageSpacesClick={this.toggleSpaceSelector}
capabilities={this.props.capabilities}
/>
);
} else {
element = (
<SpacesMenu
id={popoutContentId}
spaces={this.state.spaces}
isLoading={this.state.loading}
onSelectSpace={this.onSelectSpace}
Expand Down Expand Up @@ -140,7 +144,7 @@ export class NavControlPopover extends Component<Props, State> {
private getButton = (linkIcon: JSX.Element, linkTitle: string) => {
return (
<EuiHeaderSectionItemButton
aria-controls="headerSpacesMenuList"
aria-controls={popoutContentId}
aria-expanded={this.state.showSpaceSelector}
aria-haspopup="true"
aria-label={linkTitle}
Expand Down

0 comments on commit ea4a1ac

Please sign in to comment.