Repository navigation
Conversation
`aria-expanded` was declared on `.mzp-c-sidemenu-main`, the content the toggle controls, so assistive tech was told the menu was collapsed even when the content was visible - including on desktop, where the toggle is hidden and the content is always expanded. Declare it on the `.mzp-js-toggle` element, which the template already links to the content via `aria-controls`, and derive its state from `mzp-is-active`.
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
MzpSideMenu.init()declaredaria-expandedon.mzp-c-sidemenu-main— the content the toggle controls — instead of on the controlling element itself.aria-expandedis a state attribute for a control, so the toggle exposed no state at all, and the content node carried a state that did not describe it. On desktop that was actively wrong: the toggle is hidden (display: noneabove$mq-md) and the content is always expanded, yet the visible content keptaria-expanded="false".The toggle already has
aria-controlspointing at the content id in the template, so no markup change is needed — the attribute just moves to the element it describes, the same way navigation was fixed for #847.The state is now derived from the
mzp-is-activeclass that the CSS actually uses to show/hide the content, so it cannot desync from the visible state (and a menu that is already expanded wheninit()runs is reported as expanded).CHANGELOG.md.Issue
Fixes #999 — and mirrors the resolution of #847 (the same mistake in
.mzp-c-sidemenuvs.mzp-c-navigation-items), which was fixed by declaringaria-expandedon the menu button.Testing
Observable behavior with the component template from
components/sidebar-menu/sidebar-menu.html:aria-expanded="false", no attribute on the contentaria-expanded="true"on the content, control has no statearia-expanded="true", no attribute on the contentaria-expanded="false", matchesmzp-is-activeremovalmzp-js-toggleisdisplay: none)aria-expanded="false"forever while fully visiblenavigation.jsthatdisplay: noneelements are not readmzp-is-activearia-expanded="false", first click inverted the wrong valuetrueand follows the classChecks I ran locally:
npx eslint .— no problems;npx stylelint "**/*.scss"— clean;npm run test-build— the newtests/unit/sidemenu.jsis picked up by the spec glob and bundles successfully.npm testneeds Firefox and Chrome, which this machine does not have, so I ran the Jasmine specs headlessly against the webpack test bundle withjasmine-core7 inside jsdom instead:tests/unit/sidemenu.json the pristinemaincommit: 4 passed, 3 failed (Expected true to be false.for thearia-expandedstill present on.mzp-c-sidemenu-main;Expected null to be 'false'./Expected null to be 'true'.for the missing state on the toggle) — i.e. the new specs fail before the change.main= 39 of 55 passing; this branch = 46 of 62 passing. The 8 failures in both runs are the pre-existingReferenceError: matchMedia is not definedspecs inmenu.jsand thenavigation.jssticky block — jsdom has nomatchMedia; nothing else changed. CI (xvfb-run npm test) should run these in real browsers.Docs: added the
aria-controlsrequirement to the Side Menu readme tips, so the markup contract the JS relies on is written down, and a## Bug Fixesline inCHANGELOG.md.One judgement call worth a look in review: on desktop the toggle keeps
aria-expanded="false"while hidden.navigation.jsgoes a step further and removes the attribute when the button is not visible (viaIntersectionObserver). I kept this change to the reported defect, but I can mirror the navigation behaviour here if you'd prefer the attribute dropped on wide viewports.This review/fix was AI-assisted (Qoder Desktop); I read the code and verified the results myself, and per
AGENTS.mdthe commit does not list a model as co-author.