From 1299399eabc23f96b0ba40d1d8f1233213bbf372 Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Mon, 14 Oct 2019 09:07:14 -0500 Subject: [PATCH] Improve a11y in EuiNavDrawer (#2417) * updated docs and added focus state to button * cl * trying to make aria-label dynamic * trying to make aria-label dynamic * added missing underline property * making hover and focus behave differently * updated aria-labels * remove unneeded line * cl * use nav and avoid a11y error * remove role=presentation --- CHANGELOG.md | 1 + src-docs/src/views/nav_drawer/nav_drawer.js | 32 ++++++++------ src/components/nav_drawer/_nav_drawer.scss | 6 ++- src/components/nav_drawer/nav_drawer.js | 47 ++++++++++++--------- 4 files changed, 50 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 298710f9ff7..37dd62474da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Added `component` prop to `EuiPageBody`, switching the default from `div` to `main` ([#2410](https://github.com/elastic/eui/pull/2410)) - Added focus state to `EuiListGroupItem` ([#2406](https://github.com/elastic/eui/pull/2406)) - Added `keyboardShorcut` glyph to 'EuiIcon ([#2413](https://github.com/elastic/eui/pull/2413)) +- Improved a11y in `EuiNavDrawer` ([#2417](https://github.com/elastic/eui/pull/2417)) **Bug fixes** diff --git a/src-docs/src/views/nav_drawer/nav_drawer.js b/src-docs/src/views/nav_drawer/nav_drawer.js index 04df1470330..29a81960b07 100644 --- a/src-docs/src/views/nav_drawer/nav_drawer.js +++ b/src-docs/src/views/nav_drawer/nav_drawer.js @@ -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 = [ @@ -124,7 +128,7 @@ export default class extends Component { iconType: 'canvasApp', isActive: true, extraAction: { - ...pinExtraAction, + ...pinExtraActionFn('Canvas'), alwaysShow: true, }, }, @@ -132,35 +136,35 @@ export default class extends Component { 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: ( + this.closeBoth()} isDisabled={this.state.outsideClickDisabled}> -
- - - - - {flyoutContent} -
+ ); }