From 8949325a9cbdecef8a0be9194e25b4bf83050e2d Mon Sep 17 00:00:00 2001 From: Nathnael Date: Thu, 20 Aug 2026 11:23:55 +0000 Subject: [PATCH] fix(export-ui): indicate the selected format and default to xlsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Radio.Card's only checked cue is a border tint, which is invisible at the p="xs" the three format cards use — so the dialog gave no sign of which format was picked. ReportExportButton's cards already carry a Radio.Indicator; this adds the same one, dropped when the card was compressed to an icon-over-label stack. Default is now xlsx rather than csv: typed number and date columns mean a spreadsheet opens it without the "is this text?" pass. It falls back to dataset.formats[0] so the dialog can never preset a format the dataset does not offer. That default also made the over-cap alert misleading. It suggested switching to CSV whenever the format was not CSV, but CSV_ROW_CAP and XLSX_ROW_CAP are both 50_000 — from the new default that buys nothing. It is now gated on dataset.caps.csv > cap, so it appears only from PDF, where the cap really is lower. --- .../src/components/export/ExportDialog.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/edr-freight-web/backoffice/src/components/export/ExportDialog.tsx b/apps/edr-freight-web/backoffice/src/components/export/ExportDialog.tsx index 6c7af128c..c8b19e56d 100644 --- a/apps/edr-freight-web/backoffice/src/components/export/ExportDialog.tsx +++ b/apps/edr-freight-web/backoffice/src/components/export/ExportDialog.tsx @@ -67,7 +67,12 @@ export function ExportDialog({ opened, onClose, dataset, params }: ExportDialogP ); const [selected, setSelected] = useState(defaultKeys); - const [format, setFormat] = useState("csv"); + // xlsx by default: typed number and date columns, so a spreadsheet opens it + // without the "is this text?" pass CSV needs. Falls back to whatever the + // dataset does offer rather than presetting a format it would reject. + const [format, setFormat] = useState( + () => (dataset.formats.includes("xlsx") ? "xlsx" : dataset.formats[0]), + ); const [scope, setScope] = useState("all"); const [search, setSearch] = useState(""); const [exporting, setExporting] = useState(false); @@ -343,7 +348,15 @@ export function ExportDialog({ opened, onClose, dataset, params }: ExportDialogP return ( - + {/* Radio.Card's own checked state is a border tint + and nothing else, which reads as unselected at + this size. The Indicator is what actually says + which format is picked, as the report export + dialog's cards already do. */} + + + + {label} @@ -385,7 +398,7 @@ export function ExportDialog({ opened, onClose, dataset, params }: ExportDialogP {total?.toLocaleString()} rows exceeds the {cap.toLocaleString()}-row{" "} {FORMAT_META[format].label} limit. Narrow the filters - {format !== "csv" ? ", switch to CSV," : ""} or{" "} + {dataset.caps.csv > cap ? ", switch to CSV," : ""} or{" "} setScope(String(cap))}> export the first {cap.toLocaleString()}