Skip to content

Commit 58cd3ed

Browse files
committed
fixup! unhide input, add feedback
1 parent d448486 commit 58cd3ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

site/src/components/CopyButton/CopyButton.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ export const CopyButton: React.FC<CopyButtonProps> = ({
3434
}, 1000)
3535
} catch (err) {
3636
const input = document.createElement("input")
37-
input.hidden = true
3837
input.value = text
3938
document.body.appendChild(input)
4039
input.focus()
4140
input.select()
4241
const result = document.execCommand("copy")
4342
document.body.removeChild(input)
44-
if (!result) {
43+
if (result) {
44+
setIsCopied(true);
45+
window.setTimeout(() => {
46+
setIsCopied(false);
47+
}, 1000);
48+
} else {
4549
const wrappedErr = new Error("copyToClipboard: failed to copy text to clipboard")
4650
if (err instanceof Error) {
4751
wrappedErr.stack = err.stack

0 commit comments

Comments
 (0)