From 596b779e013e6ee9be1cf7903ebe9411557c314d Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Thu, 23 Apr 2026 16:51:16 +0200 Subject: [PATCH] fix: guard against undefined headers in MissingDataView and MatrixView Extended headers array can have empty strings that get passed as header values; guard all .toLowerCase().includes() calls with (h || ''). Co-Authored-By: Claude Sonnet 4.6 --- src/components/MatrixView.tsx | 3 +-- src/components/MissingDataView.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/MatrixView.tsx b/src/components/MatrixView.tsx index 3c34672..03a6094 100644 --- a/src/components/MatrixView.tsx +++ b/src/components/MatrixView.tsx @@ -121,8 +121,7 @@ export function MatrixView({ data, headers, rowStatuses }: MatrixViewProps) { const formatCellValue = (val: any, header: string = '') => { if (val === undefined || val === null || val === '') return ''; - // Convert header to lowercase for checks - const h = header.toLowerCase(); + const h = (header || '').toLowerCase(); // Handle date columns - Excel serial dates are numbers >= 25569 (Jan 1, 1970) if (h.includes('date') || h.includes('launch') || h.includes('ready')) { diff --git a/src/components/MissingDataView.tsx b/src/components/MissingDataView.tsx index 828df7d..1997e3d 100644 --- a/src/components/MissingDataView.tsx +++ b/src/components/MissingDataView.tsx @@ -80,14 +80,14 @@ export function MissingDataView({ data, headers, onSaveRow, onCaptureState }: Mi const pageSize = 100; const launchDateCol = useMemo(() => { - const idx = headers.findIndex(h => h.toLowerCase().includes('launch')); + const idx = headers.findIndex(h => (h || '').toLowerCase().includes('launch')); if (idx >= 0) return idx; - return headers.findIndex(h => h.toLowerCase().includes('date')); + return headers.findIndex(h => (h || '').toLowerCase().includes('date')); }, [headers]); const readyToOrderCol = useMemo(() => { - const idx = headers.findIndex(h => h.toLowerCase().includes('ready')); + const idx = headers.findIndex(h => (h || '').toLowerCase().includes('ready')); if (idx >= 0) return idx; - return headers.findIndex(h => h.toLowerCase().includes('order')); + return headers.findIndex(h => (h || '').toLowerCase().includes('order')); }, [headers]); const launchHeader = launchDateCol >= 0 ? headers[launchDateCol] : 'Launch Date';