Skip to content

Commit c2334c0

Browse files
committed
Show an error message if the url cannot be copied
1 parent 7734ca0 commit c2334c0

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/components/tutorial/TutorialWindow.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Button } from "../ui/button";
2121
import { ScrollArea } from "../ui/scroll-area";
2222
import { ScrollShadow } from "../ui/scroll-shadow";
2323
import { TutorialTableOfContents } from "./TutorialTableOfContents";
24+
import { toast } from "sonner";
2425

2526
function CopyArticleLinkButton({ activeStep }: { activeStep: string | null }) {
2627
const [copied, setCopied] = useState(false);
@@ -34,10 +35,15 @@ function CopyArticleLinkButton({ activeStep }: { activeStep: string | null }) {
3435
encodeURIComponent(activeStep.toLowerCase()),
3536
);
3637

37-
navigator.clipboard.writeText(url.toString()).then(() => {
38-
setCopied(true);
39-
setTimeout(() => setCopied(false), 2000);
40-
});
38+
navigator.clipboard
39+
.writeText(url.toString())
40+
.then(() => {
41+
setCopied(true);
42+
setTimeout(() => setCopied(false), 2000);
43+
})
44+
.catch((_) => {
45+
toast.error("Couldn't copy the url");
46+
});
4147
}, [activeStep]);
4248

4349
return (

0 commit comments

Comments
 (0)