You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When implementing filters on a table, I encountered an issue where the column value is a string, but the filter value is an array.
I have included a example case that shows the unexpected behavior.
I based it on the filter example from the docs, but modified it to include a new relationship state with the value complicated relationship. I also changed the setFilterValue call to set the value as an array (to simulate what would happen when selecting multiple possible values).
In my example selecting either "relationship" or "complicated" from the select filter will match with the value "complicated relationship".
This is due to how the array filters are implemented, assuming that both the column and the filter value are both arrays. But since the column value in this case is of type string it instead uses the includes method from the string prototype, which is what I think is unexpected behavior.
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct
I agree to follow this project's Code of Conduct
I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
The text was updated successfully, but these errors were encountered:
fbosch
changed the title
Unexpected behaviour of array filterFns (arrIncludes, arrIncludesAll, arrIncludesSome)
Unexpected behavior of array filterFns (arrIncludes, arrIncludesAll, arrIncludesSome)
Jun 20, 2024
TanStack Table version
v8.16.0
Framework/Library version
react@18.3.1
Describe the bug and the steps to reproduce it
When implementing filters on a table, I encountered an issue where the column value is a string, but the filter value is an array.
I have included a example case that shows the unexpected behavior.
I based it on the filter example from the docs, but modified it to include a new relationship state with the value
complicated relationship
. I also changed thesetFilterValue
call to set the value as an array (to simulate what would happen when selecting multiple possible values).In my example selecting either "relationship" or "complicated" from the select filter will match with the value "complicated relationship".
This is due to how the array filters are implemented, assuming that both the column and the filter value are both arrays. But since the column value in this case is of type
string
it instead uses theincludes
method from the string prototype, which is what I think is unexpected behavior.This is how it is currently implemented:
And this is how I expected it to work:
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/edit/tanstack-table-effaj4?file=src%2Fmain.tsx
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: