Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: array filterFns #5697

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions packages/table-core/src/filterFns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ const arrIncludes: FilterFn<any> = (
columnId: string,
filterValue: unknown
) => {
return row.getValue<unknown[]>(columnId)?.includes(filterValue)
if (Array.isArray(row.getValue(columnId))) {
return row.getValue<unknown[]>(columnId)?.includes(filterValue)
}
return filterValue === row.getValue(columnId)
}

arrIncludes.autoRemove = (val: any) => testFalsey(val) || !val?.length
Expand All @@ -57,9 +60,12 @@ const arrIncludesAll: FilterFn<any> = (
columnId: string,
filterValue: unknown[]
) => {
return !filterValue.some(
val => !row.getValue<unknown[]>(columnId)?.includes(val)
)
if (Array.isArray(row.getValue(columnId))) {
return !filterValue.some(
val => !row.getValue<unknown[]>(columnId)?.includes(val)
)
}
return !filterValue.some(val => val !== row.getValue(columnId))
}

arrIncludesAll.autoRemove = (val: any) => testFalsey(val) || !val?.length
Expand All @@ -69,9 +75,12 @@ const arrIncludesSome: FilterFn<any> = (
columnId: string,
filterValue: unknown[]
) => {
return filterValue.some(val =>
row.getValue<unknown[]>(columnId)?.includes(val)
)
if (Array.isArray(row.getValue(columnId))) {
return filterValue.some(val =>
row.getValue<unknown[]>(columnId)?.includes(val)
)
}
return filterValue.some(val => val === row.getValue(columnId))
}

arrIncludesSome.autoRemove = (val: any) => testFalsey(val) || !val?.length
Expand Down