An aria-hidden-focus violation means a keyboard user can reach a control that the page is trying to hide from assistive technology. A common example is a closed filter panel that slides off screen while its links and buttons stay in the Tab order. Find the ancestor with aria-hidden="true", decide when its contents should be usable, and make the rendered state and focus behavior agree.
What the aria-hidden-focus rule checks
aria-hidden="true" marks an element and its descendants as hidden from accessibility APIs. The attribute alone leaves the element's appearance and keyboard behavior in place. A focusable link inside that subtree can still receive Tab focus, and assistive technology may have no reliable information to announce. The W3C test for sequential focus inside aria-hidden content describes this mismatch, and Deque documents the corresponding axe rule.
The audit target may be a wrapper rather than the control you tab to. An inner aria-hidden="false" cannot undo a hidden ancestor. Check the full ancestor chain, especially around shared components where a parent controls visibility.
Reproduce the violation in the failing state
- Load the deployed route at the viewport where the report found the problem. If the component changes after an interaction, reproduce that state before inspecting it.
- Inspect the reported selector in DevTools. From the first suspicious link or button, run
$0.closest('[aria-hidden="true"]')in the Console to find a hidden ancestor in the same DOM tree. In a shadow root, check the host and its ancestors as well. - Tab forward and backward around the component. If focus seems to disappear, inspect
document.activeElementto see which element received it. Record the route, viewport, state, wrapper, and control.
For example, this panel may look closed if CSS translates it off screen. Its button can still receive focus.
<div id="filters" class="filters-offscreen" aria-hidden="true">
<button type="button">Clear filters</button>
</div>
Inspect the computed styles as well as the markup. Off-screen transforms, clipping, and opacity can visually hide a control while leaving it interactive. Check the accessibility tree for the panel and use the actual Tab path to verify what happens after the toggle. The keyboard accessibility testing guide covers recording the surrounding focus sequence.
Choose a fix based on who should use the controls
Visible, usable controls
Remove aria-hidden from the control or its hidden ancestor if the action is available. For a button with an icon and text, scope the attribute to the decorative icon.
<button type="button">
<span aria-hidden="true">×</span>
Clear filters
</button>
The button gets its name from the text. For an icon-only version, give the button a name and keep the icon decorative. Check the resulting name using the accessible name testing guide. W3C ARIA in HTML defines where authors can use aria-hidden.
Closed or inactive content
Use ordinary HTML hidden when a closed panel should disappear. Remove it when the panel opens, update the toggle's aria-expanded state, and move focus to a usable control before hiding a panel that currently contains focus. Inspect the actual styles if the panel still appears. A component rule such as display: grid can override the rendering behavior of hidden. HTML Standard on the hidden attribute.
<button type="button" id="filter-toggle"
aria-expanded="false" aria-controls="filters">
Filters
</button>
<div id="filters" hidden>
<button type="button">Clear filters</button>
</div>
<a href="/help">Help</a>
<script>
const toggle = document.querySelector("#filter-toggle");
const panel = document.querySelector("#filters");
toggle.addEventListener("click", () => {
panel.hidden = !panel.hidden;
toggle.setAttribute("aria-expanded", String(!panel.hidden));
});
</script>
Here the trigger stays in focus during opening and closing. If you add a Close button or Escape handler inside the panel, return focus to the trigger before hiding the panel. Keep the next Tab stop predictable in both states.
Use inert if the inactive subtree must remain rendered during an exit animation. Move focus out, mark the subtree inert as it starts closing, then hide it once the transition finishes. Remove inertness when the panel becomes usable again. Inert content cannot receive focus or normal user clicks and is excluded from the accessibility tree. For a true modal, use the native HTML dialog guide to handle background inertness and focus restoration. HTML Standard on inert subtrees.
Setting tabindex="-1" removes a control from sequential Tab navigation. Scripts can still focus it, and changing every descendant creates new work whenever the component gains a control. Likewise, aria-disabled="true" communicates disabled semantics without implementing disabled behavior. Match the fix to the whole panel state so newly added controls inherit the right behavior. W3C focus navigation tests and examples.
Test aria-hidden-focus in Playwright
This test assumes the markup above lives at /catalog, with Playwright's baseURL set to the preview origin and @axe-core/playwright installed. It checks the rule in both panel states and verifies where the keyboard actually goes.
import { expect, test } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
test("filters expose controls only while open", async ({ page }) => {
await page.goto("/catalog");
const filters = page.getByRole("button", { name: "Filters", exact: true });
const clear = page.getByRole("button", { name: "Clear filters" });
const help = page.getByRole("link", { name: "Help" });
const checkHiddenFocus = async () => {
const result = await new AxeBuilder({ page })
.withRules(["aria-hidden-focus"])
.analyze();
expect(result.violations.map(({ id, nodes }) => ({
id,
targets: nodes.map(({ target }) => target),
}))).toEqual([]);
};
await expect(filters).toHaveAttribute("aria-expanded", "false");
await filters.focus();
await page.keyboard.press("Tab");
await expect(help).toBeFocused();
await checkHiddenFocus();
await page.keyboard.press("Shift+Tab");
await expect(filters).toBeFocused();
await page.keyboard.press("Enter");
await expect(filters).toHaveAttribute("aria-expanded", "true");
await page.keyboard.press("Tab");
await expect(clear).toBeFocused();
await checkHiddenFocus();
await page.keyboard.press("Shift+Tab");
await page.keyboard.press("Enter");
await expect(filters).toHaveAttribute("aria-expanded", "false");
await page.keyboard.press("Tab");
await expect(help).toBeFocused();
});
Use the same assertions against the production build at a mobile and desktop width if the layout mounts separate copies of the controls. If the problem appears only after an open-and-close cycle, run the axe assertion again after closing. Add the affected route to your website regression tests, then verify the component with keyboard and screen-reader navigation. Playwright's accessibility testing documentation.
Check the deployed page with Slop Audit
Run Slop Audit on the public page URL and open the Accessibility violations finding when rendered browser evidence is available. Look for the rule ID and reported selectors in the axe results, then reproduce the relevant state with the steps above. Rescan the same URL after deploying the fix and keep the component test in CI for states that require an interaction to reach.