Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve a11y in EuiNavDrawer #2417

Merged
merged 14 commits into from
Oct 14, 2019
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added `currency` glyph to 'EuiIcon' ([#2398](https://github.com/elastic/eui/pull/2398))
- Migrate `EuiBreadcrumbs`, `EuiHeader` etc, and `EuiLink` to TypeScript ([#2391](https://github.com/elastic/eui/pull/2391))
- Added focus state to `EuiListGroupItem` ([#2406](https://github.com/elastic/eui/pull/2406))
- Improved a11y in `EuiNavDrawer` ([#2417](https://github.com/elastic/eui/pull/2417))

**Bug fixes**

Expand Down
32 changes: 18 additions & 14 deletions src-docs/src/views/nav_drawer/nav_drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ export default class extends Component {
color: 'subdued',
iconType: 'pin',
iconSize: 's',
'aria-label': 'Pin to top',
};

const pinExtraActionFn = val => {
pinExtraAction['aria-label'] = `Pin ${val} to top`;
return pinExtraAction;
};

this.topLinks = [
Expand Down Expand Up @@ -124,43 +128,43 @@ export default class extends Component {
iconType: 'canvasApp',
isActive: true,
extraAction: {
...pinExtraAction,
...pinExtraActionFn('Canvas'),
alwaysShow: true,
},
},
{
label: 'Discover',
href: '#/layout/nav-drawer',
iconType: 'discoverApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Discover') },
},
{
label: 'Visualize',
href: '#/layout/nav-drawer',
iconType: 'visualizeApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Visualize') },
},
{
label: 'Dashboard',
href: '#/layout/nav-drawer',
iconType: 'dashboardApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Dashboard') },
},
{
label: 'Machine learning',
href: '#/layout/nav-drawer',
iconType: 'machineLearningApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Machine learning') },
},
{
label: 'Custom Plugin (no icon)',
href: '#/layout/nav-drawer',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Custom Plugin') },
},
{
label: 'Nature Plugin (image as icon)',
href: '#/layout/nav-drawer',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Nature Plugin') },
icon: (
<EuiImage
size="s"
Expand All @@ -176,37 +180,37 @@ export default class extends Component {
label: 'APM',
href: '#/layout/nav-drawer',
iconType: 'apmApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('APM') },
},
{
label: 'Infrastructure',
href: '#/layout/nav-drawer',
iconType: 'infraApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Infrastructure') },
},
{
label: 'Log viewer',
href: '#/layout/nav-drawer',
iconType: 'loggingApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Log viewer') },
},
{
label: 'Uptime',
href: '#/layout/nav-drawer',
iconType: 'upgradeAssistantApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Uptime') },
},
{
label: 'Maps',
href: '#/layout/nav-drawer',
iconType: 'gisApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('Maps') },
},
{
label: 'SIEM',
href: '#/layout/nav-drawer',
iconType: 'securityAnalyticsApp',
extraAction: pinExtraAction,
extraAction: { ...pinExtraActionFn('SIEM') },
},
];

Expand Down
6 changes: 5 additions & 1 deletion src/components/nav_drawer/_nav_drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
transition: width $euiAnimSpeedExtraFast;
z-index: $euiZHeader + 1;

.euiListGroupItem__button {
.navDrawerExpandButton-isExpanded .euiListGroupItem__button {
padding: $euiSizeM $euiSize;
}

.navDrawerExpandButton-isCollapsed .euiListGroupItem__button {
max-width: $euiSizeXL;
}
}

&.euiNavDrawer-isCollapsed {
Expand Down
47 changes: 27 additions & 20 deletions src/components/nav_drawer/nav_drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class EuiNavDrawer extends Component {
let footerContent;
if (showExpandButton) {
footerContent = (
<EuiListGroup className="euiNavDrawer__expandButton" flush>
<EuiListGroup className="euiNavDrawer__expandButton">
<EuiI18n
tokens={[
'euiNavDrawer.sideNavCollapse',
Expand All @@ -256,6 +256,11 @@ export class EuiNavDrawer extends Component {
label={this.state.isCollapsed ? sideNavExpand : sideNavCollapse}
iconType={this.state.isCollapsed ? 'menuRight' : 'menuLeft'}
size="s"
className={
this.state.isCollapsed
? 'navDrawerExpandButton-isCollapsed'
: 'navDrawerExpandButton-isExpanded'
}
showToolTip={this.state.isCollapsed}
extraAction={{
className: 'euiNavDrawer__expandButtonLockAction',
Expand Down Expand Up @@ -319,25 +324,27 @@ export class EuiNavDrawer extends Component {
<EuiOutsideClickDetector
onOutsideClick={() => this.closeBoth()}
isDisabled={this.state.outsideClickDisabled}>
<div
className={classes}
onBlur={this.focusOut}
onFocus={this.manageFocus}
{...rest}>
<EuiFlexItem grow={false}>
<div
id="navDrawerMenu"
className={menuClasses}
onClick={this.handleDrawerMenuClick}>
{/* Put expand button first so it's first in tab order then on toggle starts the tabbing of the items from the top */}
{/* TODO: Add a "skip navigation" keyboard only button */}
{footerContent}
{modifiedChildren}
</div>
</EuiFlexItem>

{flyoutContent}
</div>
<nav>
myasonik marked this conversation as resolved.
Show resolved Hide resolved
<div
myasonik marked this conversation as resolved.
Show resolved Hide resolved
className={classes}
onBlur={this.focusOut}
onFocus={this.manageFocus}
{...rest}>
<EuiFlexItem grow={false}>
<div
id="navDrawerMenu"
className={menuClasses}
onClick={this.handleDrawerMenuClick}>
{/* Put expand button first so it's first in tab order then on toggle starts the tabbing of the items from the top */}
{/* TODO: Add a "skip navigation" keyboard only button */}
{modifiedChildren}
{footerContent}
</div>
</EuiFlexItem>

{flyoutContent}
</div>
</nav>
</EuiOutsideClickDetector>
);
}
Expand Down