Skip to content

docs: rename skip link anchor #_top#main-content (WCAG 2.4.1)#28618

Merged
pelikhan merged 2 commits intomainfrom
copilot/update-multi-device-docs-testing-report
Apr 26, 2026
Merged

docs: rename skip link anchor #_top#main-content (WCAG 2.4.1)#28618
pelikhan merged 2 commits intomainfrom
copilot/update-multi-device-docs-testing-report

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 26, 2026

The docs skip link targeted #_top — an anchor name that implies "top of page" rather than "main content", violating WCAG 2.4.1 naming clarity. Starlight doesn't expose a stable id on <main>, so the fix requires both a new anchor target and a script to create it.

Changes

  • SkipLink.astrohref="#_top"href="#main-content"
  • scripts/skip-link.ts (new) — sets id="main-content" and tabindex="-1" on Starlight's <main> element; re-runs on astro:page-load to cover client-side navigation
  • CustomHead.astro — imports skip-link.ts alongside the existing search-aria and copy-button-aria enhancement scripts

The tabindex="-1" makes <main> programmatically focusable without inserting it into the natural tab order.

Copilot AI changed the title [WIP] Update multi-device testing report for 2026-04-26 docs: rename skip link anchor #_top#main-content (WCAG 2.4.1) Apr 26, 2026
Copilot AI requested a review from gh-aw-bot April 26, 2026 17:58
@pelikhan pelikhan marked this pull request as ready for review April 26, 2026 18:01
Copilot AI review requested due to automatic review settings April 26, 2026 18:01
@github-actions github-actions Bot mentioned this pull request Apr 26, 2026
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

Updates the docs “skip to main content” link to target a clearer anchor (#main-content) for WCAG 2.4.1 naming clarity, and adds a small client-side enhancement to ensure the target exists on Starlight pages.

Changes:

  • Update the skip link target from #_top to #main-content.
  • Add a new script that assigns id="main-content" (and tabindex="-1") to the page’s <main> element, including on astro:page-load.
  • Load the new skip-link enhancement script via CustomHead.astro.
Show a summary per file
File Description
docs/src/scripts/skip-link.ts New script to create a stable skip-link target on <main> and make it focusable.
docs/src/components/SkipLink.astro Changes skip link href to #main-content.
docs/src/components/CustomHead.astro Loads the new skip-link enhancement script site-wide.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (1)

docs/src/scripts/skip-link.ts:27

  • SkipLink now targets #main-content, but this script only sets main.id = 'main-content' when <main> has no existing id. If Starlight (or another integration) adds a different id to <main> in the future, #main-content will never exist and the skip link will break. Consider ensuring #main-content always exists (e.g., set the id unconditionally, or insert a dedicated anchor element with id="main-content" without overwriting an existing id).
	if (!main.id) {
		main.id = 'main-content';
	}
  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines +10 to +14
* This script adds `id="main-content"` and `tabindex="-1"` to the `<main>`
* element so that the skip link (`href="#main-content"`) lands on the correct
* landmark and keyboard focus is reliably placed there. The `tabindex="-1"`
* attribute makes the element programmatically focusable without including it
* in the natural tab order.
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

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

The docstring says the script “adds id="main-content" and tabindex="-1" to the <main> element”, but the implementation only adds them when the attributes are missing. Either update the comment to reflect the conditional behavior, or change the implementation to always enforce the expected target (#main-content).

This issue also appears on line 25 of the same file.

Suggested change
* This script adds `id="main-content"` and `tabindex="-1"` to the `<main>`
* element so that the skip link (`href="#main-content"`) lands on the correct
* landmark and keyboard focus is reliably placed there. The `tabindex="-1"`
* attribute makes the element programmatically focusable without including it
* in the natural tab order.
* This script ensures the `<main>` element has `id="main-content"` and
* `tabindex="-1"` when those attributes are missing, so the skip link
* (`href="#main-content"`) lands on the correct landmark and keyboard focus is
* reliably placed there. The `tabindex="-1"` attribute makes the element
* programmatically focusable without including it in the natural tab order.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit e136e6d into main Apr 26, 2026
23 checks passed
@pelikhan pelikhan deleted the copilot/update-multi-device-docs-testing-report branch April 26, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔍 Multi-Device Docs Testing Report - 2026-04-26

4 participants