Skip to content

Commit 4cad868

Browse files
authored
feat: use HTML button element for copying to clipboard (#2720)
It's much more semantic to use the `<button />` HTML component rather than trying to build the same functionality out of a `<div />` so that's what is updated here. This also updates some of the classes that were on the button as they're no longer required and removes some commented out code that doesn't need to be left around. There was also a `<span />` with the contents "Copy" that I couldn't work out when it was meant to be displayed, so I swapped that over to an HTML tooltip on the `<button />`.
1 parent 35f74cb commit 4cad868

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

frontend/src/components/ui/code-copy-button.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ export default function CodeCopyButton({
3737
);
3838
}, 500);
3939
}
40-
41-
// toast.success(`copied ${type} to clipboard`, {
42-
// icon: <ClipboardCheck className="h-4 w-4" />,
43-
// });
4440
};
4541

4642
return (
@@ -49,17 +45,17 @@ export default function CodeCopyButton({
4945
<div className="overflow-x-auto whitespace-pre-wrap text-nowrap break-all pr-4 text-sm">
5046
{!isMobile && children ? children : "Copy install command"}
5147
</div>
52-
<div
53-
className={cn(" right-0 cursor-pointer bg-muted px-3 py-4")}
48+
<button
5449
onClick={() => handleCopy("install command", children)}
50+
className={cn("bg-muted px-3 py-4")}
51+
title="Copy"
5552
>
5653
{hasCopied ? (
5754
<CheckIcon className="h-4 w-4" />
5855
) : (
5956
<ClipboardIcon className="h-4 w-4" />
6057
)}
61-
<span className="sr-only">Copy</span>
62-
</div>
58+
</button>
6359
</Card>
6460
</div>
6561
);

0 commit comments

Comments
 (0)