Skip to content

Fix false positive missing-content audit for hidden anchors#16016

Merged
ematipico merged 3 commits into
withastro:mainfrom
felmonon:fix-a11y-hidden-anchor
Jun 2, 2026
Merged

Fix false positive missing-content audit for hidden anchors#16016
ematipico merged 3 commits into
withastro:mainfrom
felmonon:fix-a11y-hidden-anchor

Conversation

@felmonon

Copy link
Copy Markdown
Contributor

Summary

  • use text content instead of innerText for dev-toolbar a11y name checks
  • cover anchors inside closed
    Details so hidden-but-valid text is not flagged
  • reuse the same text-content check for label and aria-labelledby paths

Testing

  • pnpm run build:ci
  • pnpm exec playwright test e2e/dev-toolbar-audits.test.js

Fixes #16009

@changeset-bot

changeset-bot Bot commented Mar 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1ce69a8

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

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

codspeed-hq Bot commented Mar 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing felmonon:fix-a11y-hidden-anchor (1ce69a8) with main (a595623)

Open in CodSpeed

'Headings and anchors must have an accessible name, which can come from: text content, aria-label, aria-labelledby, an img with alt property, or an svg with a tag <title></title>.',
selector: a11y_required_content.join(','),
match(element: HTMLElement) {
// innerText is used to ignore hidden text

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we used innerText on purpose, as this removed comment explains.

@matthewp matthewp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we intentionally use innerText

@felmonon felmonon force-pushed the fix-a11y-hidden-anchor branch from 16868f4 to 1ce69a8 Compare May 1, 2026 18:28
@felmonon

felmonon commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

Updated this to keep the existing innerText behavior and only skip elements hidden by a closed <details>. I also added a regression case so hidden-only text still produces a11y-missing-content, while the anchor inside closed details does not.\n\nLocal checks:\n- pnpm --dir packages/astro run build:ci\n- pnpm --dir packages/astro exec playwright test e2e/dev-toolbar-audits.test.ts

@ematipico ematipico merged commit 0d85e1b into withastro:main Jun 2, 2026
27 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Jun 2, 2026
ematipico added a commit that referenced this pull request Jun 2, 2026
* chore: move integration tests to unit tests (#16869)

* chore(deps): replace which-pm-runs with package-manager-detector (#16901)

* chore(deps): update dependency hono to v4.12.18 [security] (#16669)

* Fix false positive missing-content audit for hidden anchors (#16016)

* fix: remove dead else branch in csp insertDirective (#16921)

Co-authored-by: Emanuele Stoppa <[email protected]>

* chore: avoid formatter conflicts (#16897)

---------

Co-authored-by: ocavue <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Felmon <[email protected]>
Co-authored-by: Stefan Machhammer <[email protected]>
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Jun 6, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`6.4.2` → `6.4.3`](https://renovatebot.com/diffs/npm/astro/6.4.2/6.4.3) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/6.4.3?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/6.4.2/6.4.3?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (astro)</summary>

### [`v6.4.3`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#643)

[Compare Source](https://github.com/withastro/astro/compare/[email protected]@6.4.3)

##### Patch Changes

- [#&#8203;16900](withastro/astro#16900) [`17a0fbd`](withastro/astro@17a0fbd) Thanks [@&#8203;ocavue](https://github.com/ocavue)! - Bumps `devalue` dependency to v5.8.1

- [#&#8203;16016](withastro/astro#16016) [`0d85e1b`](withastro/astro@0d85e1b) Thanks [@&#8203;felmonon](https://github.com/felmonon)! - Fix a false positive in the dev toolbar accessibility audit for anchors with text inside closed `<details>` elements.

- [#&#8203;16911](withastro/astro#16911) [`79c6c46`](withastro/astro@79c6c46) Thanks [@&#8203;astrobot-houston](https://github.com/astrobot-houston)! - Fixes a bug where `experimental.advancedRouting` with `astro/hono` handlers threw `TypeError: Cannot read properties of undefined (reading 'route')` for unmatched routes instead of rendering the custom 404 page.

- [#&#8203;16899](withastro/astro#16899) [`239c469`](withastro/astro@239c469) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes a false "does not call the middleware() handler" warning when using `astro()` in a custom `src/app.ts` and the first request is a redirect route.

- [#&#8203;16887](withastro/astro#16887) [`493acdb`](withastro/astro@493acdb) Thanks [@&#8203;astrobot-houston](https://github.com/astrobot-houston)! - Fixes `redirectToDefaultLocale` not working after the Advanced Routing refactoring.

- [#&#8203;16908](withastro/astro#16908) [`ef53ab9`](withastro/astro@ef53ab9) Thanks [@&#8203;florian-lefebvre](https://github.com/florian-lefebvre)! - Improves optimized fallbacks generation when using the Fonts API by using better metrics for bold variants

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMDUuMyIsInVwZGF0ZWRJblZlciI6IjQzLjIwNS4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
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.

A11y audit false positive on anchors that are not shown initially

3 participants