Skip to content

Commit

Permalink
fix(megamenu): remove menu role for accessibility (carbon-design-syst…
Browse files Browse the repository at this point in the history
…em#5160)

### Related Ticket(s)

Web component: Mega Menu - "The essentials, Hybrid Cloud" are read as menu options for screen reader users. carbon-design-system#5081

### Description

This PR removes the `role='menu'` from the `ul` as it is unnecessary and conflicts with the elements placed in the megamenu/dropdown.

PR here from carbon-for-ibm-dotcom where we removed the menu role from our own version of the header menu
carbon-design-system#4624

The dropdown menu/megamenu shouldn't have the role="menu" applied as listed here:
Example Disclosure for Navigation Menus | WAI-ARIA Authoring Practices 1.1
https://www.w3.org/TR/wai-aria-practices/examples/disclosure/disclosure-navigation.html

<img width="950" alt="Screen Shot 2020-12-03 at 4 25 20 PM" src="https://user-images.githubusercontent.com/54281166/101090282-661c0680-3584-11eb-8dd0-b43ca6f9aa7e.png">

### Changelog

**Changed**

- grab the `bx--header-menu` element and remove the `role` attribute


<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "package: styles": Carbon Expressive -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
annawen1 authored and IgnacioBecerra committed Feb 22, 2021
1 parent cffb465 commit 40e19bc
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* LICENSE file in the root directory of this source tree.
*/

import { customElement } from 'lit-element';
import { customElement, query } from 'lit-element';
import settings from 'carbon-components/es/globals/js/settings';
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
import { forEach } from '../../globals/internal/collection-helpers';
Expand All @@ -25,6 +25,12 @@ const { stablePrefix: ddsPrefix } = ddsSettings;
*/
@customElement(`${ddsPrefix}-megamenu-top-nav-menu`)
class DDSMegaMenuTopNavMenu extends DDSTopNavMenu {
/**
* The menu ul node.
*/
@query(`.${prefix}--header__menu`)
private _menuNode!: HTMLElement;

/**
* The observer for the resize of the viewport.
*/
Expand Down Expand Up @@ -71,6 +77,7 @@ class DDSMegaMenuTopNavMenu extends DDSTopNavMenu {
}

firstUpdated() {
this._menuNode.removeAttribute('role');
this._cleanAndCreateObserverResize({ create: true });
}

Expand Down

0 comments on commit 40e19bc

Please sign in to comment.