From 1dde65f901596ec30bfccab5e8a16cb8a3a7a7d2 Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Thu, 23 Apr 2026 02:32:07 -0700 Subject: [PATCH] address review: coerce numeric timestamp strings before dateFormatters --- .../src/react-pivottable/TableRenderers.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx index d841af8256c..4944392bf46 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx @@ -1005,8 +1005,18 @@ export function TableRenderer({ /> ); }; + // Coerce numeric timestamp strings to numbers so temporal formatters + // (which typically expect an epoch) render correctly. + const rawHeaderCellValue = colKey[attrIdx]; + const headerCellFormatterValue = + typeof rawHeaderCellValue === 'string' && + rawHeaderCellValue.trim() !== '' && + Number.isFinite(Number(rawHeaderCellValue)) + ? Number(rawHeaderCellValue) + : rawHeaderCellValue; const headerCellFormattedValue = - dateFormatters?.[attrName]?.(colKey[attrIdx]) ?? colKey[attrIdx]; + dateFormatters?.[attrName]?.(headerCellFormatterValue) ?? + rawHeaderCellValue; const isActiveHeader = colLabelClass.includes('active'); const { backgroundColor, color } = getCellColor( [attrName], @@ -1274,8 +1284,16 @@ export function TableRenderer({ ? toggleRowKey(flatRowKeySlice) : null; + // Coerce numeric timestamp strings to numbers so temporal formatters + // (which typically expect an epoch) render correctly. + const headerFormatterValue = + typeof r === 'string' && + r.trim() !== '' && + Number.isFinite(Number(r)) + ? Number(r) + : r; const headerCellFormattedValue = - dateFormatters?.[settingsRowAttrs[i]]?.(r) ?? r; + dateFormatters?.[settingsRowAttrs[i]]?.(headerFormatterValue) ?? r; const isActiveHeader = valueCellClassName.includes('active'); const { backgroundColor, color } = getCellColor( [settingsRowAttrs[i]],