Skip to content

fix(a11y): avoid missing-content false positives in closed details#16163

Open
Misrilal-Sah wants to merge 6 commits into
withastro:mainfrom
Misrilal-Sah:fix/a11y-missing-content-details-16009
Open

fix(a11y): avoid missing-content false positives in closed details#16163
Misrilal-Sah wants to merge 6 commits into
withastro:mainfrom
Misrilal-Sah:fix/a11y-missing-content-details-16009

Conversation

@Misrilal-Sah
Copy link
Copy Markdown
Contributor

Issue ID : #16009

Description: Uses a safer text-content check for accessibility missing-content detection and adds regression coverage so hidden-initial-state

Copilot AI review requested due to automatic review settings March 31, 2026 17:25
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 31, 2026

⚠️ No Changeset found

Latest commit: 6331b5c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Mar 31, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 31, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing Misrilal-Sah:fix/a11y-missing-content-details-16009 (6331b5c) with main (b51f297)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (a7e7567) during the generation of this report, so b51f297 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Dev Toolbar accessibility audit to avoid false-positive “missing content” findings for anchors/headings that start out hidden inside a closed <details> element, and adds an e2e regression to cover that scenario.

Changes:

  • Add a shared hasAccessibleTextContent() helper that prefers innerText but falls back to textContent.
  • Use the helper for both direct element checks and aria-labelledby referenced elements in the a11y-missing-content rule.
  • Add an e2e fixture page and a new audit test to ensure no highlights are produced for closed-<details> content with valid text.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/a11y.ts Adjusts missing-content detection logic to avoid closed-<details> false positives.
packages/astro/e2e/fixtures/dev-toolbar/src/pages/a11y-missing-content-details.astro Adds a minimal reproduction page with closed <details> containing valid link/heading text.
packages/astro/e2e/dev-toolbar-audits.test.js Adds a regression test asserting no audit highlights for the new fixture page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +273 to +277
const auditCanvas = toolbar.locator('astro-dev-toolbar-app-canvas[data-app-id="astro:audit"]');
const auditHighlights = auditCanvas.locator('astro-dev-toolbar-highlight');

const count = await auditHighlights.count();
expect(count).toEqual(0);
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The test uses await auditHighlights.count() which doesn’t wait for the audit UI to finish rendering/running; it can read 0 immediately after clicking the app button even if highlights appear a moment later. To make this regression test reliable, prefer a locator assertion that auto-waits (e.g. await expect(auditHighlights).toHaveCount(0)), optionally after waiting for the audit canvas/window to be visible.

Copilot uses AI. Check for mistakes.
@matthewp
Copy link
Copy Markdown
Contributor

Test failures are unrelated, but need to fix in main first.

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

  • changeset missing
  • restore PR template
  • use magic comments to auto close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants