From 025115e0822a03028a38f8aa2195a3a0b1e75db5 Mon Sep 17 00:00:00 2001 From: sunith vs <63339782+sunithvs@users.noreply.github.com> Date: Sat, 17 May 2025 20:55:52 +0400 Subject: [PATCH] fix: prevent popup blocking when downloading resume --- www/components/ClientResumeButton.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/components/ClientResumeButton.tsx b/www/components/ClientResumeButton.tsx index 6007ff0b..1fe4fcae 100644 --- a/www/components/ClientResumeButton.tsx +++ b/www/components/ClientResumeButton.tsx @@ -12,6 +12,7 @@ export default function ClientResumeButton({ username }: { username: string }) { const [isLoading, setIsLoading] = useState(false); const handleDownload = async () => { + const newWindow = window.open("", "_blank"); try { setIsLoading(true); const response = await fetch(`/api/resume?username=${username}`); @@ -22,9 +23,14 @@ export default function ClientResumeButton({ username }: { username: string }) { const blob = await response.blob(); const url = URL.createObjectURL(blob); - window.open(url, "_blank"); + if (newWindow) { + newWindow.location.href = url; + } else { + window.open(url, "_blank"); + } } catch (error) { console.error("Error downloading resume:", error); + if (newWindow) newWindow.close(); } finally { setIsLoading(false); }