diff --git a/frontend/src/components/ExportDataModal.jsx b/frontend/src/components/ExportDataModal.jsx index 3e0e2c1..72f487b 100644 --- a/frontend/src/components/ExportDataModal.jsx +++ b/frontend/src/components/ExportDataModal.jsx @@ -15,7 +15,7 @@ function triggerDownload(filename, text) { document.body.appendChild(a); a.click(); document.body.removeChild(a); - URL.revokeObjectURL(url); + setTimeout(() => URL.revokeObjectURL(url), 0); } export default function ExportDataModal({ experimentTitle, experimentId, dailyTemplate, animals, onClose }) { @@ -37,12 +37,9 @@ export default function ExportDataModal({ experimentTitle, experimentId, dailyTe const params = useMemo(() => listExportableParams(dailyTemplate, statuses), [dailyTemplate, statuses]); - // Default the selection to the first parameter once params are available. - useEffect(() => { - if (selectedId === null && params.length > 0) setSelectedId(params[0].id); - }, [params, selectedId]); - - const selectedParam = params.find((p) => p.id === selectedId) ?? null; + // Derive the effective selection: the user's pick, else the first parameter. + const effectiveId = selectedId ?? params[0]?.id ?? null; + const selectedParam = params.find((p) => p.id === effectiveId) ?? null; const matrix = useMemo( () => (selectedParam ? buildMatrix(statuses, animals, selectedParam) : { columns: [], rows: [] }), @@ -69,7 +66,14 @@ export default function ExportDataModal({ experimentTitle, experimentId, dailyTe } if (loading) return
Loading data…
; - if (error) return