diff --git a/src/components/src/common/data-table/index.tsx b/src/components/src/common/data-table/index.tsx index e7e244ac13..6204b75807 100644 --- a/src/components/src/common/data-table/index.tsx +++ b/src/components/src/common/data-table/index.tsx @@ -219,8 +219,11 @@ const getRowCell = ( const {type} = colMeta[column]; let value = dataContainer.valueAt(rowIdx, columns.indexOf(column)); - if (value === undefined) value = 'Err'; - return formatter ? formatter(value) : parseFieldValue(value, type); + return value === null || value === undefined || value === '' + ? '' + : formatter + ? formatter(value) + : parseFieldValue(value, type); }; type StatsControlProps = { diff --git a/src/utils/src/data-utils.ts b/src/utils/src/data-utils.ts index e90bbb71af..786385805b 100644 --- a/src/utils/src/data-utils.ts +++ b/src/utils/src/data-utils.ts @@ -454,5 +454,6 @@ export function datetimeFormatter( .utc(ts) .tz(timezone) .format(format) - : format => ts => moment.utc(ts).format(format); + : // return empty string instead of 'Invalid date' if ts is undefined/null + format => ts => (ts ? moment.utc(ts).format(format) : ''); } diff --git a/test/node/utils/data-utils-test.js b/test/node/utils/data-utils-test.js index ffaca5d39c..10dddbe67a 100644 --- a/test/node/utils/data-utils-test.js +++ b/test/node/utils/data-utils-test.js @@ -192,6 +192,30 @@ test('dataUtils -> getFormatter', t => { { input: ['yn'], assert: [true, 'yes'] + }, + { + input: ['L LT'], + assert: ['2011-04-10 00:00', '04/10/2011 12:00 AM'] + }, + { + input: ['L LT'], + assert: [null, ''] + }, + { + input: ['L LT'], + assert: [undefined, ''] + }, + { + input: ['L LT'], + assert: ['', ''] + }, + { + input: ['L'], + assert: ['2011-04-10', '04/10/2011'] + }, + { + input: ['L'], + assert: [null, ''] } ];