Thanks for using the beta version of React Table v7! We're very excited about it.
Describe the bug
I use react-table with row selection and filter functionality, and when I filter some rows and click on select all (header checkbox), I try to deselect one of the rows it does not work properly
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Deselect will work properly when you try to deselect them after the filter and select all
Codesandbox!
https://codesandbox.io/s/upbeat-frost-7m6v4
Maybe I use the component, not in the right way I just combined filter and row selection examples.
If you apply a filter to the table it snapshots the rows state, so when you would try to select or deselect the row it would only work once, so you couldn't select then deselect a row without changing the filters. It would throw it out as if you were trying to transition to the same state.
I was able to fix it locally, though I only fixed it for this situation and only tested for this situation.
So I changed the useRowSelect toggleRowSelected reducer so it would check the the rows that are selected in state to see if the id exists in the object.
Will #1925 fix this?
No, that commit is to fix changing the state of only rows that are visible while a filter is applied using the toggleAll check. Currently it will deselect rows that are not visible. The tests that are in place only test using the toggleAll feature instead of the toggle individual rows. The problem that I proposed is interacting with a single column while a filter is applied.
This is now fixed to my knowledge with recent PRs
Most helpful comment
The Issue
If you apply a filter to the table it snapshots the rows state, so when you would try to select or deselect the row it would only work once, so you couldn't select then deselect a row without changing the filters. It would throw it out as if you were trying to transition to the same state.
How to reproduce
My Solution
I was able to fix it locally, though I only fixed it for this situation and only tested for this situation.
So I changed the useRowSelect toggleRowSelected reducer so it would check the the rows that are selected in state to see if the id exists in the object.
My Solution