Skip to content

Commit f3d2ea8

Browse files
authored
Merge pull request #4849 from PoorShawn/fix/null-data-filter
fix: properly handle null or undefined data in filter plugin
2 parents 51fb5b3 + 631ee3e commit f3d2ea8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/vtable-plugins/src/filter/value-filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class ValueFilter {
105105
// 空行不做处理
106106
if (isValid(record)) {
107107
const originalValue = record[fieldId];
108-
const formattedValue = formatFn(record);
108+
const formattedValue = formatFn(record) ?? '(空白)';
109109
if (formattedValue !== undefined && formattedValue !== null) {
110110
countMap.set(formattedValue, (countMap.get(formattedValue) || 0) + 1);
111111

@@ -155,7 +155,7 @@ export class ValueFilter {
155155
// 空行不做处理
156156
if (isValid(record)) {
157157
const originalValue = record[candidateField];
158-
const formattedValue = formatFn(record);
158+
const formattedValue = formatFn(record) ?? '(空白)';
159159
countMap.set(formattedValue, (countMap.get(formattedValue) || 0) + 1);
160160
if (formattedValue !== undefined && formattedValue !== null) {
161161
const unformattedSet = toUnformatted.get(formattedValue);

0 commit comments

Comments
 (0)