Skip to content

Commit

Permalink
main and nav landmark a11y fixes (#48381)
Browse files Browse the repository at this point in the history
* main and nav landmark a11y fixes

* deduping i18n keys

* renaming appNav aria-label prop
  • Loading branch information
Michail Yasonik authored Oct 18, 2019
1 parent f13949a commit 894fff0
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 27 deletions.
22 changes: 18 additions & 4 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,26 @@ class HeaderUI extends Component<Props, State> {
data-test-subj="navDrawer"
isLocked={isLocked}
onIsLockedUpdate={onIsLockedUpdate}
aria-label={i18n.translate('core.ui.primaryNav.screenReaderLabel', {
defaultMessage: 'Primary',
})}
>
<nav>
<EuiNavDrawerGroup listItems={recentLinksArray} />
<>
<EuiNavDrawerGroup
listItems={recentLinksArray}
aria-label={i18n.translate('core.ui.recentLinks.screenReaderLabel', {
defaultMessage: 'Recently viewed links, navigation',
})}
/>
<EuiHorizontalRule margin="none" />
<EuiNavDrawerGroup data-test-subj="navDrawerAppsMenu" listItems={navLinksArray} />
</nav>
<EuiNavDrawerGroup
data-test-subj="navDrawerAppsMenu"
listItems={navLinksArray}
aria-label={i18n.translate('core.ui.primaryNavList.screenReaderLabel', {
defaultMessage: 'Primary navigation links',
})}
/>
</>
</EuiNavDrawer>
</header>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="devApp app-container">
<!-- Tabs. -->
<main class="devApp app-container">
<!-- Tabs. -->
<div class="euiTabs" role="tablist">
<a
role="tab"
aria-selected="{{kbnDevToolsApp.currentPath === item.url}}"
aria-selected="{{ kbnDevToolsApp.currentPath === item.url }}"
ng-repeat="item in kbnDevToolsApp.devTools"
class="euiTab"
ng-class="{'euiTab-isSelected': kbnDevToolsApp.currentPath === item.url, 'euiTab-isDisabled': item.disabled}"
Expand All @@ -18,5 +18,5 @@
{{::item.display}}
</a>
</div>
<main class="devApp__container" role="tabpanel" ng-transclude></main>
</div>
<div class="devApp__container" role="tabpanel" ng-transclude></div>
</main>
4 changes: 2 additions & 2 deletions src/legacy/ui/public/chrome/directives/kbn_chrome.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="app-wrapper-panel">
<div id="globalBannerList"></div>

<main
<div
class="application"
ng-class="'tab-' + getFirstPathSegment() + ' ' + chrome.getApplicationClasses()"
ng-view
></main>
></div>
</div>
4 changes: 4 additions & 0 deletions src/legacy/ui/public/management/components/sidebar_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { EuiIcon, EuiSideNav, IconType } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { IndexedArray } from 'ui/indexed_array';

Expand Down Expand Up @@ -73,6 +74,9 @@ export class SidebarNav extends React.Component<SidebarNavProps, SidebarNavState
public render() {
return (
<EuiSideNav
aria-label={i18n.translate('common.ui.management.nav.label', {
defaultMessage: 'Management',
})}
mobileTitle={this.renderMobileTitle()}
isOpenOnMobile={this.state.isSideNavOpenOnMobile}
toggleOpenOnMobile={this.toggleOpenOnMobile}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/apm/public/new-platform/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { MatchedRouteProvider } from '../context/MatchedRouteContext';

export const REACT_APP_ROOT_ID = 'react-apm-root';

const MainContainer = styled.div`
const MainContainer = styled.main`
min-width: ${px(unit * 50)};
padding: ${px(units.plus)};
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class AdminPage extends React.PureComponent<Props, State> {

public render() {
return (
<div className="codeContainer__root">
<main className="codeContainer__root">
<div className="codeContainer__rootInner">
<div className="codeContainer__adminWrapper">
<SearchBar
Expand All @@ -147,7 +147,7 @@ class AdminPage extends React.PureComponent<Props, State> {
</div>
</div>
</div>
</div>
</main>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import React from 'react';
import euiStyled from '../../../../../common/eui_styled_components';

interface AppNavigationProps {
'aria-label': string;
children: React.ReactNode;
}

export const AppNavigation = ({ children }: AppNavigationProps) => (
<Nav>
export const AppNavigation = ({ 'aria-label': label, children }: AppNavigationProps) => (
<Nav aria-label={label}>
<EuiFlexGroup gutterSize="m" alignItems="center" justifyContent="spaceBetween">
<EuiFlexItem>{children}</EuiFlexItem>
</EuiFlexGroup>
Expand All @@ -25,7 +26,7 @@ const Nav = euiStyled.nav`
border-bottom: ${props => props.theme.eui.euiBorderThin};
padding: ${props =>
`${props.theme.eui.euiSize} ${props.theme.eui.euiSizeL} ${props.theme.eui.euiSize} ${props.theme.eui.euiSizeL}`}
.euiTabs {
padding-left: 3px;
margin-left: -3px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ export class InfraKibanaFrameworkAdapter implements InfraFrameworkAdapter {
}),
scope: true,
template: `
<div
<main
id="${ROOT_ELEMENT_ID}"
class="infReactRoot"
></div>
></main>
`,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const InfrastructurePage = injectUICapabilities(
readOnlyBadge={!uiCapabilities.infrastructure.save}
/>

<AppNavigation>
<AppNavigation
aria-label={i18n.translate('xpack.infra.header.infrastructureNavigationTitle', {
defaultMessage: 'Metrics',
})}
>
<RoutedTabs
tabs={[
{
Expand Down
9 changes: 5 additions & 4 deletions x-pack/legacy/plugins/infra/public/pages/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export const LogsPage = injectUICapabilities(({ match, uiCapabilities }: LogsPag
}),
path: `${match.path}/settings`,
};
const pageTitle = i18n.translate('xpack.infra.header.logsTitle', {
defaultMessage: 'Logs',
});
return (
<Source.Context.Provider value={source}>
<LogAnalysisCapabilities.Context.Provider value={logAnalysisCapabilities}>
Expand All @@ -110,9 +113,7 @@ export const LogsPage = injectUICapabilities(({ match, uiCapabilities }: LogsPag
<Header
breadcrumbs={[
{
text: i18n.translate('xpack.infra.header.logsTitle', {
defaultMessage: 'Logs',
}),
text: pageTitle,
},
]}
readOnlyBadge={!uiCapabilities.logs.save}
Expand All @@ -129,7 +130,7 @@ export const LogsPage = injectUICapabilities(({ match, uiCapabilities }: LogsPag
/>
) : (
<>
<AppNavigation>
<AppNavigation aria-label={pageTitle}>
<RoutedTabs
tabs={
logAnalysisCapabilities.hasLogAnalysisCapabilites
Expand Down
7 changes: 6 additions & 1 deletion x-pack/legacy/plugins/siem/public/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as React from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
import { pure } from 'recompose';
import styled from 'styled-components';
import { i18n } from '@kbn/i18n';

import { AutoSizer } from '../../components/auto_sizer';
import { DragDropContextWrapper } from '../../components/drag_and_drop/drag_drop_context_wrapper';
Expand Down Expand Up @@ -104,7 +105,11 @@ export const HomePage = pure(() => (
</Flyout>

<EuiPageBody>
<NavGlobal>
<NavGlobal
aria-label={i18n.translate('xpack.siem.global.navigationLabel', {
defaultMessage: 'SIEM app',
})}
>
<EuiFlexGroup alignItems="center" gutterSize="m" justifyContent="spaceBetween">
<EuiFlexItem>
<SiemNavigation navTabs={navTabs} />
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/uptime/public/uptime_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const Application = (props: UptimeAppProps) => {
<UptimeRefreshContext.Provider value={{ lastRefresh, ...rootRouteProps }}>
<UptimeSettingsContext.Provider value={initializeSettingsContextValues()}>
<EuiPage className="app-wrapper-panel " data-test-subj="uptimeApp">
<div>
<main>
<EuiFlexGroup
alignItems="center"
justifyContent="spaceBetween"
Expand Down Expand Up @@ -200,7 +200,7 @@ const Application = (props: UptimeAppProps) => {
/>
<Route component={NotFoundPage} />
</Switch>
</div>
</main>
</EuiPage>
</UptimeSettingsContext.Provider>
</UptimeRefreshContext.Provider>
Expand Down

0 comments on commit 894fff0

Please sign in to comment.