Skip to content

fix(switcher): wrap SwitcherDivider hr in li for a11y compliance#20632

Merged
maradwan26 merged 12 commits into
carbon-design-system:mainfrom
nehaaprasad:fix/switcher-list
May 11, 2026
Merged

fix(switcher): wrap SwitcherDivider hr in li for a11y compliance#20632
maradwan26 merged 12 commits into
carbon-design-system:mainfrom
nehaaprasad:fix/switcher-list

Conversation

@nehaaprasad

Copy link
Copy Markdown
Contributor

closes #20619

  • The SwitcherDivider was rendering an <hr> element directly inside a <ul>, which violates WCAG 2.1 standards. This fix wraps the <hr> in an <li> element to maintain proper list structure while preserving the visual appearance and functionality.

Changed

  • SwitcherDivider now renders <hr> wrapped in <li> instead of standalone <hr> for accessibility compliance

Testing / Reviewing

  • Verify SwitcherDivider still renders visually the same in Storybook examples
  • Check that accessibility tools (axe-core) no longer flag the list structure violation
  • Confirm SwitcherDivider works correctly in UIShell Header examples
  • Test keyboard navigation still works properly in Switcher components

@nehaaprasad nehaaprasad requested a review from a team as a code owner October 1, 2025 18:55
@github-actions

github-actions Bot commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

All contributors have signed the DCO.
Posted by the DCO Assistant Lite bot.

@netlify

netlify Bot commented Oct 1, 2025

Copy link
Copy Markdown

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit bbe57eb
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-web-components/deploys/6a0207ac8d44550008160ca9
😎 Deploy Preview https://deploy-preview-20632--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Oct 1, 2025

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit bbe57eb
🔍 Latest deploy log https://app.netlify.com/projects/carbon-elements/deploys/6a0207ac972a5a00088a573e
😎 Deploy Preview https://deploy-preview-20632--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Oct 1, 2025

Copy link
Copy Markdown

Deploy Preview for v11-carbon-react ready!

Name Link
🔨 Latest commit bbe57eb
🔍 Latest deploy log https://app.netlify.com/projects/v11-carbon-react/deploys/6a0207ac9f2ab800088884b2
😎 Deploy Preview https://deploy-preview-20632--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@emyarod emyarod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently see this duplicated horizontal rule, and I believe the class names need to be placed on the hr to resolve this

image

@nehaaprasad

Copy link
Copy Markdown
Contributor Author

@emyarod
check please out!

@tay1orjones

Copy link
Copy Markdown
Member

@naaa760 You'll need to complete the DCO before this can be merged. Instructions in the comment above #20632 (comment)

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate is still present

Image

<SwitcherItem aria-label="Link 1" href="#">
Link 1
</SwitcherItem>
<SwitcherDivider />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @emyarod stated, the styles need to be modified to apply to the correct element. Removing the SwitcherDivider from the story is not a fix for the problem.

@nehaaprasad

Copy link
Copy Markdown
Contributor Author

I have read the DCO document and I hereby sign the DCO.

@nehaaprasad

Copy link
Copy Markdown
Contributor Author

@tay1orjones
please check now!

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? I think the classnames should apply to the same element as before.

Comment on lines +30 to +32
<li className={classNames}>
<hr {...other} />
</li>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<li className={classNames}>
<hr {...other} />
</li>
<li>
<hr {...other} className={classNames} />
</li>

Comment on lines +48 to +56

hr {
border: none;
margin: 0;
padding: 0;
background: transparent;
block-size: 1px;
inline-size: 100%;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hr {
border: none;
margin: 0;
padding: 0;
background: transparent;
block-size: 1px;
inline-size: 100%;
}

@nehaaprasad

Copy link
Copy Markdown
Contributor Author

@tay1orjones
fixed it!
let me know!

@codecov

codecov Bot commented Jan 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.13%. Comparing base (ff3e1f5) to head (bbe57eb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20632      +/-   ##
==========================================
- Coverage   95.15%   95.13%   -0.02%     
==========================================
  Files         549      549              
  Lines       45650    45650              
  Branches     6532     6575      +43     
==========================================
- Hits        43437    43429       -8     
- Misses       2083     2091       +8     
  Partials      130      130              
Flag Coverage Δ
main-packages 89.22% <100.00%> (ø)
web-components 97.91% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maradwan26

Copy link
Copy Markdown
Contributor

@naaa760
Tests are failing for the SwitcherDivider, could you check?

Comment thread packages/styles/scss/components/ui-shell/switcher/_switcher.scss Outdated
Co-authored-by: Mahmoud <132728978+maradwan26@users.noreply.github.com>

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this and added tests. LGTM

@maradwan26 maradwan26 enabled auto-merge May 11, 2026 16:50
@maradwan26 maradwan26 added this pull request to the merge queue May 11, 2026
Merged via the queue into carbon-design-system:main with commit 9cdf860 May 11, 2026
40 checks passed
@tay1orjones tay1orjones self-assigned this May 12, 2026
@tay1orjones tay1orjones moved this to ✅ Done in Design System May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

[a11y]: Inside the Switcher we are using SwitcherDivider getting error Ensure that lists are structured correctly

6 participants