Skip to content

Commit

Permalink
fix(ui-shell): a11y issue with side nav item (#11044)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

Closes #10918

### Description

The bx-side-nav-menu-item tag in UI Shell component throws accessibility error.
 
### Changelog


**Changed**

- Added role attribute value button to the element.


<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
<img width="1696" alt="Screenshot 2023-10-17 at 3 51 06 PM" src="https://github.com/carbon-design-system/carbon-for-ibm-dotcom/assets/58620134/e4264482-547e-4bc0-bc18-6bb5dde8b785">
  • Loading branch information
sangeethababu9223 authored Oct 26, 2023
1 parent 47f627c commit 9eb94ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class BXSideNavMenuItem extends FocusMixin(LitElement) {
return true;
}

connectedCallback() {
if (!this.hasAttribute('role')) {
this.setAttribute('role', 'button');
}
super.connectedCallback();
}

render() {
const { active, href, title } = this;
const classes = classMap({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<dds-left-nav-menu-item
data-autoid="dds--masthead__l0--sidenav--nav0"
href="https://carbon-design-system.github.io/carbon-for-ibm-dotcom/canary/web-components/foo"
role="button"
title="item-title-foo"
>
</dds-left-nav-menu-item>
Expand All @@ -106,6 +107,7 @@
<dds-left-nav-menu-item
data-autoid="dds--masthead__l0--sidenav--nav1-list0"
href="https://carbon-design-system.github.io/carbon-for-ibm-dotcom/canary/web-components/bar"
role="button"
title="menu-item-title-bar"
>
</dds-left-nav-menu-item>
Expand Down

0 comments on commit 9eb94ea

Please sign in to comment.