From 519a896ec1c73ff2fa24555d446e86c607cc84b7 Mon Sep 17 00:00:00 2001 From: OpenClaw Bot Date: Sun, 8 Mar 2026 10:56:50 +0100 Subject: [PATCH] fix: open fallback window only on PDF export failure --- public/index.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 192e688..06c5acc 100644 --- a/public/index.html +++ b/public/index.html @@ -498,13 +498,13 @@ function closeAiModal(){ } async function downloadPdf(){ - const fallbackWin = window.open('', '_blank'); const openPrintFallback = (msg='') => { if (msg) alert(msg); - if (!fallbackWin) return; - fallbackWin.document.write(`Coachingcards PDF${app.innerHTML}`); - fallbackWin.document.close(); - fallbackWin.onload = () => setTimeout(() => fallbackWin.print(), 200); + const w = window.open('', '_blank'); + if (!w) return; + w.document.write(`Coachingcards PDF${app.innerHTML}`); + w.document.close(); + w.onload = () => setTimeout(() => w.print(), 200); }; if (!window.html2canvas || !window.jspdf?.jsPDF) { @@ -551,7 +551,6 @@ async function downloadPdf(){ } pdf.save(`coachingcards-${new Date().toISOString().slice(0,10)}.pdf`); - if (fallbackWin && !fallbackWin.closed) fallbackWin.close(); } catch (e) { console.error('PDF export failed', e); openPrintFallback('PDF-Download fehlgeschlagen – nutze Druckdialog als Fallback.');