gregnb / gregnb/mui-datatables
custom filter, removed chip provide wrong `filterPos` when its value is 0
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
## Expected Behavior
Consider case where my `filterList` is [1, 0, 2].
In `update` function of `customFilterListOptions` I should get index of removed value. When I remove chip with value 0 (index=1 in provided case), the `filterPos` should be 1.
## Current Behavior
It works properly in almost all casses, but when removed chip/value is 0, `filterPos` is -1.
## Steps to Reproduce (for bugs)
codesandbox: https://codesandbox.io/s/custom-filter-chip-issue-3qtm2x?file=/src/index.tsx
step to reproduce:
1. Remove `User` chip
`Admin` is removed instead.
## Your Environment
| Tech | Version |
|--------------|---------|
| Material-UI | 5.11.15 |
| MUI-datatables | 4.3.0 |
| React | 18.2.0 |
| browser | Chrome |
## Additional Info
I found that this issue may be caused by this line
https://github.com/gregnb/mui-datatables/blob/a382f3e8e850c7fcdd395f8594a5e0afefcaf905/src/components/TableFilterList.js#L63
`item[customFilterItemIndex]` of value 0 is consider as false and then `[]` is passed.
Then here https://github.com/gregnb/mui-datatables/blob/a382f3e8e850c7fcdd395f8594a5e0afefcaf905/src/MUIDataTable.js#L1372
value could not be found and -1 is returned;
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.