Different item is selected when selected item is deleted
Current Behavior
Let's say i want to delete one or more items, the current behavior is to select other items if the datasource has changed and items are no longer available.
Expected Behavior
I don't know if this is a bug but i expect there is no selection active after deleting items.
Your Environment
| Tech | Version |
|---|---|
| Material-UI | 4.11 |
| MUI-datatables | 3.4.1 |
| React | 16.13.1 |
| browser | Chrome 84.0.4147.135 |
I don't understand. This is no selection active after deleting an item.
I tried to reproduce in a codesandbox but it's working as expected so i will close the this issue. This is likely related to my own code.
Can you take a look at the following sandbox: https://codesandbox.io/s/wandering-browser-f0em9?file=/src/App.js
As i can see my issue is related to the customToolbarSelect;
This is interesting. When the data is updated, the internal rowsSelected and rowsExpanded state values should reset. Your updates are causing a re-render, but for some reason those values appear to be staying intact. I'll have to investigate this more later.
As a workaround, you can use the option "rowsSelected" and manually indicate which rows are selected. The only catch you is have to use the onRowSelectionChange callback to make sure this array stays properly updated.
Thank you for the update, i will use the workaround for now.
I have also experienced this issue. The interesting thing is that in case data field is updated, then selection indeed is nullified, but ir row in data is deleted, then the selection stays active.
updated my lib and seeing this behavior now too