mui-datatables
mui-datatables copied to clipboard
selection persists after changing page
in case of options.serverSide: true selecting a row then changing page will select the corresponding row on the next page if number of rows changed from the first page to the second.
most likely due to this condition https://github.com/gregnb/mui-datatables/blob/ca67aaeb1602b4585e145b361151ce62a8b2d3dd/src/MUIDataTable.js#L333
Steps to Reproduce (for bugs)
- run https://github.com/gregnb/mui-datatables/blob/master/examples/serverside-pagination/index.js changing
rowsPerPageto 15. - select the first row of the first page.
- go to next page.
- the first row of the second page is selected by default!
Expected Behavior
selected rows should be reset after changing page.
Current Behavior
in case number of rows changed from a page to another the data change won't be detected and the corresponding rows of the same page will be selected.
Your Environment
running an example included in the repo in chrome.
| Tech | Version |
|---|---|
| MUI-datatables | 3.4.1 & master |
| browser | chrome |
It can be replicated here: https://j8pbp.sse.codesandbox.io/#serverside-pagination
How to reproduce:
- Select the first row
- Navigate to the next page
- The first row in the second page is selected!
- Unselect the first row in page 2
- Navigate back to the first page
- The first row in the first page is unselected!
Also experiencing this issue.
Unfortunately git blame doesn't give a commit message that's of any use so I don't know the rationale behind:
didDataUpdate = didDataUpdate && this.props.data.length === prevProps.data.length;
I'm guessing it'd make more sense as:
didDataUpdate = didDataUpdate || this.props.data.length !== prevProps.data.length;
Any fix for workaround for this?
I'm also facing that issue - is there a solution yet?