Skip to content

Commit 781beb7

Browse files
authored
fix: prevent toLowerCase() is not a function filterFn error(#4776)
1 parent b14b7af commit 781beb7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/table-core/src/filterFns.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ const includesString: FilterFn<any> = (
66
filterValue: string
77
) => {
88
const search = filterValue.toLowerCase()
9-
return Boolean(row.getValue<string>(columnId)?.toLowerCase().includes(search))
9+
return Boolean(
10+
row
11+
.getValue<string | null>(columnId)
12+
?.toString()
13+
?.toLowerCase()
14+
.includes(search)
15+
)
1016
}
1117

1218
includesString.autoRemove = (val: any) => testFalsey(val)
@@ -16,7 +22,9 @@ const includesStringSensitive: FilterFn<any> = (
1622
columnId: string,
1723
filterValue: string
1824
) => {
19-
return Boolean(row.getValue<string>(columnId)?.includes(filterValue))
25+
return Boolean(
26+
row.getValue<string | null>(columnId)?.toString()?.includes(filterValue)
27+
)
2028
}
2129

2230
includesStringSensitive.autoRemove = (val: any) => testFalsey(val)
@@ -27,7 +35,8 @@ const equalsString: FilterFn<any> = (
2735
filterValue: string
2836
) => {
2937
return (
30-
row.getValue<string>(columnId)?.toLowerCase() === filterValue.toLowerCase()
38+
row.getValue<string | null>(columnId)?.toString()?.toLowerCase() ===
39+
filterValue?.toLowerCase()
3140
)
3241
}
3342

0 commit comments

Comments
 (0)