Skip to content

[a11y] Fix nested interactive elements in Copyable component (WCAG 4.1.2)#3558

Open
rosanusi wants to merge 1 commit into
mainfrom
wcag/4.1.2-copyable-nested-interactive
Open

[a11y] Fix nested interactive elements in Copyable component (WCAG 4.1.2)#3558
rosanusi wants to merge 1 commit into
mainfrom
wcag/4.1.2-copyable-nested-interactive

Conversation

@rosanusi

Copy link
Copy Markdown
Contributor

Summary

  • Replaces outer <button> wrapper in clickAllToCopy mode with a <div class="group">, moving the click-to-copy action into an inner <button> sibling of CopyButton
  • Eliminates nested interactive elements (button inside button), which violates WCAG 2.2 SC 4.1.2 (Name, Role, Value)
  • The inner button gets aria-label={\Copy ${content}`}` so screen readers announce it meaningfully
  • The group class stays on the <div>, so group-hover:visible / group-focus-within:visible Tailwind utilities continue to work for the CopyButton reveal
  • No consumer changes required — the fix is entirely within the primitive

Test plan

  • Verify clickAllToCopy mode renders <div> wrapping two sibling buttons (no button-in-button)
  • Tab to the inner copy button and confirm screen reader announces "Copy [content]"
  • Hover over the component and confirm CopyButton becomes visible via group-hover:visible
  • Focus the inner button and confirm CopyButton stays visible via group-focus-within:visible
  • Click the inner button and confirm content is copied to clipboard

A11y-Audit-Ref: 4.1.2-copyable-nested-interactive

🤖 Generated with Claude Code

Replaces outer <button> wrapper in clickAllToCopy mode with a <div>,
moving click-to-copy into an inner <button> sibling of CopyButton.
Eliminates WCAG 2.2 SC 4.1.2 violation (button inside button).

A11y-Audit-Ref: 4.1.2-copyable-nested-interactive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
holocene Ready Ready Preview, Comment Jun 12, 2026 3:25pm

Request Review

@rosanusi rosanusi marked this pull request as ready for review June 12, 2026 15:34
@rosanusi rosanusi requested a review from a team as a code owner June 12, 2026 15:34
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