fix(editor): PDF export download keeps its URL alive (WebKit may cancel)

This commit is contained in:
bchanot committed 2026-10-18 04:53:45 +02:00
1 parent ae17097afb
commit 2b8000e5ab
3 files changed
+32 -15

No files matched your search

+5 -7
View File
@@ -33,6 +33,7 @@ import type { SheetIndex } from '@/services/sheetIndex'
import { pickLabel } from '@/i18n/pickLocaleLabel'
import type { ViewStates } from '@/anatomy/drawing'
import { exportReportToPdf } from '@/pdf/export'
import { downloadBlob } from '@/lib/download'
import type { ExportWarning } from '@faunosteo/pdf'
import type { RebaseOutcome } from '@faunosteo/core-wasm/types'
import { useT } from '@/i18n/useT'
@@ -236,13 +237,10 @@ export default function EditorRoute() {
const { pdf, warnings } = await exportReportToPdf(report, index, {
locale,
})
const blob = new Blob([pdf as BlobPart], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `bilan-${report.animal.name}-${report.date}.pdf`
a.click()
URL.revokeObjectURL(url)
downloadBlob(
new Blob([pdf as BlobPart], { type: 'application/pdf' }),
`bilan-${report.animal.name}-${report.date}.pdf`,
)
const missing = missingItemsOf(warnings)
if (missing.length) {
window.alert(