Sage / carbon

Carbon by Sage | ReactJS UI Component Library
https://carbon.sage.com
Apache License 2.0
277 stars 86 forks source link

Select + Grouped Options - Critical AXE issue: ARIA roles contain invalid children #6718

Open justin-rankin opened 4 months ago

justin-rankin commented 4 months ago

Description

For Carbon Select dropdown menu with grouped Options: AXE DevTools correctly displays what is flagged as a critical accessibility issue:

"Certain ARIA roles must contain particular children"

h4-CRITICAL-AXE


This critical issue is being caused by Carbon's rendering of the <h4> tag in the DOM, as a sibling to of the list of (correct) <li> node, that are the only valid children of the parent <ul> tag...

<ul>
  <h4>Group - A</h4> <!--- πŸ‘ˆπŸΌ invalid child DOM node --> 
  <li>Option A1</li>
  <li>Option A2</li>
  <li>Option A3</li>
  <h4>Group - B</h4> <!--- πŸ‘ˆπŸΌ invalid child DOM node --> 
  <li>Option B1</li>
  <li>Option B2</li>
  <li>Option b3</li>
</ul>

h4-in-DOM


Even if <h4> is wrapped inside of a <li> tag, AXE still gives an accessibility warning about semantical order of the heading <h1...h5 /> tags, though the warning level which is no longer critical.


Reproduction

https://carbon.sage.com/?path=/docs/select--docs#option-groups

Steps to reproduce

This is produced simply by using the documented <OptionGroupHeader /> component among the array of <Option /> components, when implementing the <Select />, which purpose is to visually and group options via a bold non-option, non-clickable heading..

JIRA ticket numbers (Sage only)

SBS-92771

Suggested solution

In order to avoid this AXE warning, perhaps the <OptionGroupHeader /> component could:

Carbon version

v134.0.0 (latest, and older versions)

Design tokens version

No response

Relevant browsers

Firefox, Chrome, Safari, Microsoft Edge

Relevant OSs

MacOS, Windows, Linux

Additional context

No response

Confidentiality

nineteen88 commented 4 months ago

FE-6571

DipperTheDan commented 4 months ago

I'll be addressing this as part of the work in ticket FE-6285.