Skip to content

Commit 631ee3e

Browse files
committed
fix: properly handle null or undefined data in filter plugin
1 parent 043d740 commit 631ee3e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 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

@@ -139,7 +139,7 @@ export class ValueFilter {
139139
records = this.table.internalProps.records;
140140
} else {
141141
const recordsList = this.getRecords(this.table, true); // 已筛选:使用原始表格数据
142-
const records = recordsList.filter(record =>
142+
records = recordsList.filter(record =>
143143
filteredFields.every(field => {
144144
const filterType = this.filterStateManager.getFilterState(field)?.type;
145145
if (filterType !== 'byValue' && filterType !== null && filterType !== undefined) {
@@ -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)