Skip to content

Commit

Permalink
fix: prevent toLowerCase() is not a function filterFn error(#4776)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy authored Mar 26, 2023
1 parent b14b7af commit 781beb7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/table-core/src/filterFns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ const includesString: FilterFn<any> = (
filterValue: string
) => {
const search = filterValue.toLowerCase()
return Boolean(row.getValue<string>(columnId)?.toLowerCase().includes(search))
return Boolean(
row
.getValue<string | null>(columnId)
?.toString()
?.toLowerCase()
.includes(search)
)
}

includesString.autoRemove = (val: any) => testFalsey(val)
Expand All @@ -16,7 +22,9 @@ const includesStringSensitive: FilterFn<any> = (
columnId: string,
filterValue: string
) => {
return Boolean(row.getValue<string>(columnId)?.includes(filterValue))
return Boolean(
row.getValue<string | null>(columnId)?.toString()?.includes(filterValue)
)
}

includesStringSensitive.autoRemove = (val: any) => testFalsey(val)
Expand All @@ -27,7 +35,8 @@ const equalsString: FilterFn<any> = (
filterValue: string
) => {
return (
row.getValue<string>(columnId)?.toLowerCase() === filterValue.toLowerCase()
row.getValue<string | null>(columnId)?.toString()?.toLowerCase() ===
filterValue?.toLowerCase()
)
}

Expand Down

0 comments on commit 781beb7

Please sign in to comment.