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

custom filter, removed chip provide wrong filterPos when its value is 0 #2017

Open
zksteel opened this issue Jul 28, 2023 · 1 comment
Open

Comments

@zksteel
Copy link

zksteel commented Jul 28, 2023

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

item[customFilterItemIndex] || [],

item[customFilterItemIndex] of value 0 is consider as false and then [] is passed.

Then here

const filterPos = filterList[index].indexOf(value);

value could not be found and -1 is returned;

@zksteel
Copy link
Author

zksteel commented Jul 28, 2023

Could anyone suggest a quick fix? I need it to work until it will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant