From 8edf2594b1fc883541c5f6b94de70100812562a5 Mon Sep 17 00:00:00 2001 From: Sabrina Bongiovanni Date: Fri, 29 Dec 2023 16:03:23 +0100 Subject: [PATCH] fix: porting of v2 accessibility for megamenu --- .../ItaliaTheme/MegaMenu/MegaMenu.jsx | 24 +++++++++++++------ .../MenuSecondary/MenuSecondary.jsx | 5 ++-- .../theme/Navigation/Navigation.jsx | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx b/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx index 7a17726ac..1508f2f42 100644 --- a/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx +++ b/src/components/ItaliaTheme/MegaMenu/MegaMenu.jsx @@ -112,17 +112,18 @@ const MegaMenu = ({ item, pathname }) => { if (item.mode === 'simpleLink') { return item.linkUrl?.length > 0 ? ( - + {isItemActive && ( - + {intl.formatMessage(messages.menu_selected)} )} @@ -238,7 +239,7 @@ const MegaMenu = ({ item, pathname }) => { } return ( - + { } }} title={intl.formatMessage(messages.closeMenu)} + // APG spec: on Tab menu closes, so remove it from focusable elements + // https://www.w3.org/WAI/ARIA/apg/patterns/menubar/examples/menubar-navigation/ + tabIndex="-1" > @@ -278,10 +282,14 @@ const MegaMenu = ({ item, pathname }) => { {childrenGroups.map((group, index) => ( - + {group.map((child, idx) => { return ( -
  • +
  • {child.showAsHeader ? (

    { key={child['@id']} onClick={() => setMenuStatus(false)} role="menuitem" + aria-current="page" > {child.title} @@ -362,12 +371,13 @@ const MegaMenu = ({ item, pathname }) => { - -
  • + +
  • setMenuStatus(false)} + role="menuitem" > {item.showMoreText?.length > 0 diff --git a/src/components/ItaliaTheme/MenuSecondary/MenuSecondary.jsx b/src/components/ItaliaTheme/MenuSecondary/MenuSecondary.jsx index 4dfd91056..c596d944d 100644 --- a/src/components/ItaliaTheme/MenuSecondary/MenuSecondary.jsx +++ b/src/components/ItaliaTheme/MenuSecondary/MenuSecondary.jsx @@ -44,17 +44,18 @@ const MenuSecondary = ({ pathname }) => { return ( items?.length > 0 && ( -