jbetancur / react-data-table-component

A responsive table library with built-in sorting, pagination, selection, expandable rows, and customizable styling.
https://react-data-table-component.netlify.app
Apache License 2.0
2.04k stars 411 forks source link

onSelectedRowsChange called when search is submitted #1178

Open StuartMorris0 opened 10 months ago

StuartMorris0 commented 10 months ago

Issue Check list

Describe the bug

We have a table that uses selectable rows. When a user searches, the value is used to filter down the data for the table and display the filtered results. This all works as expected. The issue relates to selected rows. We use a callback as described in docs for the selected rows.

What happens is the onSelectedRowsChange function is called when search is submitted/data changes and causes an empty selectedRows attribute.

We see the search as being a data filter, not an entire new set of data. Therefore if you select a row, then search for data where the initial selection is not within, you loose the initial selection. I'd expect the same selection to be held in state whilst a filter is taking place (search). Otherwise if the search term is removed, so is your original selection.