a11y: Label the code-block copy button - #2003
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
marcleblanc2
marked this pull request as ready for review
September 18, 2026 05:40
valerybugakov
approved these changes
Sep 18, 2026
marcleblanc2
force-pushed
the
marc/a11y/copy-button-name
branch
from
September 18, 2026 05:58
515e80b to
78a5da7
Compare
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>
marcleblanc2
force-pushed
the
marc/a11y/copy-button-name
branch
from
September 18, 2026 06:02
78a5da7 to
b6ddbbf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) andtype="button".Verification
npx tsc --noEmitandpnpm run lintclean. 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.