Skip to content

a11y: Label the code-block copy button - #2003

Draft
marcleblanc2 wants to merge 1 commit into
mainfrom
marc/a11y/copy-button-name
Draft

marcleblanc2 wants to merge 1 commit into
mainfrom
marc/a11y/copy-button-name

Conversation

@marcleblanc2

Copy link
Copy Markdown
Contributor

Problem

The copy button on every code block (src/components/CopyButton.tsx) has only an icon, so assistive tech announces an unnamed button (WCAG 4.1.2).

Fix

Add aria-label ("Copy code", flipping to "Copied" so the state change is announced) and type="button".

Verification

npx tsc --noEmit and pnpm run lint clean. Inspect any code block: button[aria-label="Copy code"].

Related: #1994 (sidebar toggle labels) and #1996 (landmarks) covered the other unnamed controls.

Found by the docs site audit in this Amp thread; rebuilt locally in this one.

The copy button on code blocks had no accessible name, so screen readers
announced an unlabelled button. Add an aria-label that flips to Copied,
and type=button so it never submits a surrounding form.

Found by the docs site audit in
https://ampcode.com/threads/T-01a0ae50-f7f0-779c-aa66-3887c9953e33

Amp-Thread-ID: https://ampcode.com/threads/T-01a0aed2-5fbe-7768-85ea-1378bf98f9ff
Co-authored-by: Amp <amp@ampcode.com>
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sourcegraph-docs Ready Ready Preview Sep 17, 2026 10:43am UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

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.

1 participant