mirror of
https://github.com/apache/superset.git
synced 2026-05-06 16:34:32 +00:00
address review: coerce numeric timestamp strings before dateFormatters
This commit is contained in:
@@ -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]],
|
||||
|
||||
Reference in New Issue
Block a user