Remove invalid role="menu" from the navbar collapse toggler - #14805
Open
cwickham wants to merge 3 commits into
Open
Remove invalid role="menu" from the navbar collapse toggler#14805cwickham wants to merge 3 commits into
role="menu" from the navbar collapse toggler#14805cwickham wants to merge 3 commits into
Conversation
role="menu" was added to navtoggle.ejs in #9553 because Lighthouse (running an older axe-core built on ARIA 1.1) reported that the button role did not support aria-expanded. ARIA 1.2 allows aria-expanded on button, so the override is no longer needed — and it was never a valid role for the element: axe-core flags it as aria-allowed-role, and WAVE treats a menu with no menuitem children as an Error (aria_menu_broken) mapped to WCAG 2.2 SC 2.1.1 and 4.1.2. A follow-up commit in #9553 already replaced role="menu" on the dropdown toggles; the hamburger toggler was the remaining instance. The toggler now matches Bootstrap's own navbar-toggler markup: native button semantics with aria-controls, aria-expanded, and aria-label. Adds a website smoke-all regression test that asserts the rendered toggler carries aria-expanded, aria-controls, and aria-label but no role attribute. Fixes #14615
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
The 1.10 changelog established a dedicated Accessibility section for this kind of entry. Also add /_site/ to the smoke-all fixture's .gitignore: the harness cleans output after a run, but an interrupted run would otherwise leave an untracked _site behind.
cwickham
marked this pull request as ready for review
August 25, 2026 18:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #14615.
The website navbar's hamburger toggle rendered as a
<button>withrole="menu". That role is not valid on a button. axe-core reports it asaria-allowed-role. WAVE reports the same markup as an Error (aria_menu_broken), mapped to WCAG 2.2 SC 2.1.1 and 4.1.2, because amenumust contain at least onemenuitemchild. The toggle only appears when the navbar collapses at narrow viewports, so the violation only shows in mobile-width scans.Why the role was there. #9553 (May 2024) added roles because Lighthouse reported that
role="button"did not supportaria-expanded. That was true under ARIA 1.1, which the axe-core of that time used. ARIA 1.2 permitsaria-expandedon thebuttonrole, so the override is no longer needed. A second commit in #9553 already replacedrole="menu"on the dropdown toggles withrole="link". The hamburger toggler was the one instance left.The fix. Remove the
roleattribute. The button keepsaria-controls,aria-expanded, and its "Toggle navigation" label. This matches the markup in Bootstrap's own navbar documentation, which carries norole. A repo-wide search found no otherrole="menu", and no CSS, JS, or test keys off it.Verification. With the two-file repro from the issue at a 600 px viewport: 1 axe-core violation (
aria-allowed-roleon.navbar-toggler) before the fix, 0 after, with best-practice rules on. After the fix, a click still flipsaria-expandedtotrueand opens the collapse.New test. A website smoke-all test (
tests/docs/smoke-all/website/navbar-toggler-role/) asserts that the rendered toggler carriesaria-expanded,aria-controls, andaria-labelbut noroleattribute. The fix is a static template change, so no browser test is needed. The test fails against the old markup (verified by temporarily restoringrole="menu").Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.