Introduction
A shared accordion component on an enterprise marketing site failed the Lighthouse “Agentic Browsing” audit. The page rendered correctly and nobody had reported anything. The cause was a structural ARIA mistake: a panel role placed inside a container that declared itself a tablist.
Because the accordion is a design-system component, one fix covers every page that uses it. The harder question was how to prove the change was invisible. This tutorial walks through the method.
The symptom: one audit fails, the page looks fine
Nothing about the page was wrong to the eye. The accordion opened and closed, the content was there, the keyboard reached the buttons. What failed was the structure a screen reader or an AI agent sees: the roles claimed one widget pattern (tabs) while the elements behaved as another (an accordion). Automated audits check exactly this kind of claim, and so do assistive tools.
Why it only fails on desktop
The first run came back clean. That is the trap: Lighthouse emulates a mobile device by default, and on mobile this component renders a different branch of the layout. The desktop-only accordion is never in the page the audit sees.
Run the audit with the desktop preset:
lighthouse https://example.com/page --preset=desktop --only-categories=accessibility --output=json
With the desktop preset the failure appears and the score moves. In this project the audit went from 0.67 to 1.0 after the fix.
Lesson to carry over: if an audit passes on mobile emulation, check whether the failing block exists there at all. Any component with a desktop-only branch needs its own desktop run.
Find the mismatch: ARIA role vs the element it sits on
ARIA widget roles come in patterns, and the pattern has to be complete. A tablist owns tab elements, and its tabpanel elements live outside the list. An accordion is a different pattern: a group of buttons, each with aria-expanded and aria-controls, and a panel that is a labelled region.
The desktop branch of the component had borrowed the tab roles without the tab structure. The fix was to stop claiming to be tabs:
- the container became a plain
group; - each trigger button got
aria-expandedandaria-controlspointing at its panel; - the open panel became a
regionlabelled by its button througharia-labelledby.
The mobile branch, which was already a real tablist with its panels outside the list, stayed untouched.
Fix the shared component, not the page
The failing page was one of many that use the accordion. Fixing the markup on that page would have passed that one audit and left the rest failing silently. The change went into the component, and every page picked it up on the next build.
A second page then failed for a different defect of the same family: a list element carrying a panel role. It got a wrapper element with the correct role and the same verification. Same lesson in the other direction — a family of defects usually has more than one member, and the audit only reports the first one it meets on the page it is given.
Prove “no visual change”: same-environment before/after shots
“No visual change” is a claim, and a claim about pixels needs pixel evidence. The method:
- Run the old code and the new code on the same development server, one after the other.
- Take screenshots of the affected pages at three widths — 375, 1024 and 1440 — from each.
- Compare them pixel for pixel. The expected result is identical images.
The one trap: the control must be the same environment. The first comparison used the production site as “before” and the development server as “after”, and they differed at 1440 by a small offset that had nothing to do with the fix — fonts, cache, environment. Same server, old code versus new code, is the only before/after that proves anything.
Crawl the other pages for the same pattern
One page fails the audit; the question is how many more carry the same markup. Rather than auditing every page by hand, walk the sitemap, render each page, and search the resulting DOM for a panel role inside a tablist.
This turns “we fixed the page that failed” into “we checked every page and none has the pattern”. It also finds the second defect family mentioned above — the list with a panel role — which a per-page audit would have reached only by luck.
Write the rule into the design-system docs
The last step is the one that prevents the next occurrence. The rule — ARIA widget roles must match the element pattern they sit on; a tablist’s panels live outside it; an accordion is a group of expandable buttons with labelled regions — went into the design-system documentation as its own accessibility page, next to the components it applies to, with the audit command that checks it.
A developer building the next collapsible block now finds the rule where they find the component. That is the difference between a fix and a pattern.
Takeaway
An accessibility failure with no visible symptom is still a failure for every reader who depends on structure rather than pixels. Audit with the preset that actually renders the block, fix the shared component rather than the page, prove the pixels with a same-environment comparison, crawl for the pattern elsewhere, and write the rule down where the component lives.