From 1b55948228dab68247755275dda5c51f070b528f Mon Sep 17 00:00:00 2001 From: Jennifer Giardino Date: Fri, 22 Sep 2017 09:48:27 -0400 Subject: [PATCH] fix(vertical nav): improve accessibility support Update css to apply hover styles on menu items with focus Update css to prevent keyboard Tab key from shiftin focus to hidden elements Update html test page example to include aria attributes for better screenreader support --- src/less/vertical-nav.less | 63 ++++++++------ .../navigation/secondary-nav-amet.html | 25 ++++-- .../navigation/secondary-nav-ipsum.html | 26 ++++-- .../navigation/tertiary-amet-corrumpit.html | 16 ++-- .../navigation/tertiary-amet-detracto.html | 16 ++-- .../navigation/tertiary-amet-mediocrem.html | 16 ++-- .../navigation/tertiary-ipsum-copiosae.html | 16 ++-- .../navigation/tertiary-ipsum-intellegam.html | 16 ++-- .../navigation/tertiary-ipsum-patrioque.html | 16 ++-- .../navigation/vertical-navigation.html | 83 ++++++++++--------- 10 files changed, 176 insertions(+), 117 deletions(-) diff --git a/src/less/vertical-nav.less b/src/less/vertical-nav.less index 758d997ba9..19dd1430b7 100644 --- a/src/less/vertical-nav.less +++ b/src/less/vertical-nav.less @@ -92,21 +92,21 @@ text-align: center; width: @nav-pf-vertical-icon-width; } - &:hover { + &:hover, + &:focus { text-decoration: none; } } - &.active, - &:hover { - > a { - background-color: @nav-pf-vertical-active-bg-color; - color: @nav-pf-vertical-active-color; - font-weight: @nav-pf-vertical-active-font-weight; - .fa, - .glyphicon, - .pficon { - color: @nav-pf-vertical-active-icon-color; - } + &.active > a, + &:hover > a, + & > a:focus { + background-color: @nav-pf-vertical-active-bg-color; + color: @nav-pf-vertical-active-color; + font-weight: @nav-pf-vertical-active-font-weight; + .fa, + .glyphicon, + .pficon { + color: @nav-pf-vertical-active-icon-color; } } &.active { @@ -590,12 +590,12 @@ &.active > a:before { display: none; } - &.active, - &:hover { - > a { - background-color: @nav-pf-vertical-secondary-active-bg-color; - color: @nav-pf-vertical-secondary-active-color; - } + &.active > a, + &:hover > a, + & > a:focus { + background-color: @nav-pf-vertical-secondary-active-bg-color; + color: @nav-pf-vertical-secondary-active-color; + text-decoration: none; } .badge-container-pf { top: 5px; @@ -894,20 +894,16 @@ } } .nav-pf-vertical-collapsible-menus { - .secondary-collapse-toggle-pf { - display: inline-block; - } .secondary-nav-item-pf.active { .secondary-collapse-toggle-pf { + display: inline-block; opacity: 1; pointer-events: all; } } - .tertiary-collapse-toggle-pf { - display: inline-block; - } .tertiary-nav-item-pf.active { .tertiary-collapse-toggle-pf { + display: inline-block; opacity: 1; pointer-events: all; } @@ -948,3 +944,22 @@ transition: visibility @nav-pf-menu-transition-period, opacity @nav-pf-menu-transition-period linear; } } + +// make hidden parent menu items not keyboard-accessible when a submenu is +// pinned or the mobile nav is shown +.list-group > .list-group-item > a { + .collapsed-tertiary-nav-pf > &, + .collapsed-tertiary-nav-pf .nav-pf-secondary-nav > &, + .show-mobile-tertiary > &, + .show-mobile-tertiary .nav-pf-secondary-nav > &, + .collapsed-secondary-nav-pf > &, + .show-mobile-secondary > & { + display: none; + } +} +.secondary-nav-item-pf.active .secondary-collapse-toggle-pf { + .show-mobile-tertiary.nav-pf-vertical-collapsible-menus &, + .collapsed-tertiary-nav-pf.nav-pf-vertical-collapsible-menus & { + display: none; + } +} diff --git a/tests/pages/_includes/widgets/navigation/secondary-nav-amet.html b/tests/pages/_includes/widgets/navigation/secondary-nav-amet.html index 2d208158ed..0ab87696a1 100644 --- a/tests/pages/_includes/widgets/navigation/secondary-nav-amet.html +++ b/tests/pages/_includes/widgets/navigation/secondary-nav-amet.html @@ -1,11 +1,16 @@ -