Skip to content

Commit 779bd69

Browse files
Renjiroyalpinto007
andauthored
a11y: make comment permalink button keyboard-visible and named (#67)
CommentAnchorLink only revealed on hover, so a focused button had no visible indicator (WCAG 2.4.7), and its accessible name was the "#" character via title. Add focus-visible:opacity-100, swap title for aria-label, hide the glyph from assistive tech, and announce the copied state via a live region. Co-authored-by: royalpinto007 <royalpinto007@gmail.com>
1 parent ece0d71 commit 779bd69

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

components/post/CommentsSection.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ function CommentAnchorLink({ commentId }: { commentId: string }) {
4040
return (
4141
<button
4242
onClick={copy}
43-
className="font-mono text-[10px] text-text-tertiary opacity-0 transition-opacity group-hover:opacity-100 hover:text-text-secondary"
44-
title="Copy link to comment"
43+
className="font-mono text-[10px] text-text-tertiary opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 hover:text-text-secondary"
44+
aria-label="Copy link to this comment"
4545
>
46-
{copied ? "Copied" : failed ? "Failed" : "#"}
46+
<span aria-hidden="true">
47+
{copied ? "Copied" : failed ? "Failed" : "#"}
48+
</span>
49+
<span aria-live="polite" className="sr-only">
50+
{copied ? "Copied" : failed ? "Failed to copy" : ""}
51+
</span>
4752
</button>
4853
);
4954
}

0 commit comments

Comments
 (0)