Skip to content

Commit 1c070b4

Browse files
committed
Review fixes
1 parent c6b3896 commit 1c070b4

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

ui/src/components/ScreenshotRenderer/ScreenshotPreviewModal.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useState } from "react";
1+
import { useCallback, useEffect, useRef, useState } from "react";
22
import { Check, Copy, Download } from "lucide-react";
33

44
import { Button } from "@/components/Button/Button";
@@ -30,6 +30,11 @@ export function ScreenshotPreviewModal({
3030
}: ScreenshotPreviewModalProps) {
3131
const [copied, setCopied] = useState(false);
3232
const toast = useToast();
33+
const copyTimerRef = useRef<ReturnType<typeof setTimeout>>();
34+
35+
useEffect(() => {
36+
return () => clearTimeout(copyTimerRef.current);
37+
}, []);
3338

3439
const handleDownload = useCallback(() => {
3540
downloadBlob(blob, generateScreenshotFilename(title));
@@ -39,7 +44,8 @@ export function ScreenshotPreviewModal({
3944
try {
4045
await navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]);
4146
setCopied(true);
42-
setTimeout(() => setCopied(false), 2000);
47+
clearTimeout(copyTimerRef.current);
48+
copyTimerRef.current = setTimeout(() => setCopied(false), 2000);
4349
} catch {
4450
toast.error("Copy failed", "Your browser may not support copying images");
4551
}

ui/src/components/ScreenshotRenderer/ScreenshotRenderer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export function ScreenshotRenderer({
9191
return createPortal(
9292
<div
9393
ref={containerRef}
94+
aria-hidden="true"
9495
className={`${themeClass} bg-background text-foreground`}
9596
style={{
9697
position: "fixed",

ui/src/hooks/useScreenshotExport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export function useScreenshotExport() {
1414
const toast = useToast();
1515

1616
const startCapture = useCallback(() => {
17+
if (objectUrlRef.current) {
18+
URL.revokeObjectURL(objectUrlRef.current);
19+
objectUrlRef.current = null;
20+
}
21+
setScreenshot(null);
1722
setIsCapturing(true);
1823
toast.info("Capturing screenshot…", "Rendering all messages");
1924
}, [toast]);

0 commit comments

Comments
 (0)