mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

selection persists after changing page

Open 7sean68 opened this issue 4 years ago • 5 comments

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)

  1. run https://github.com/gregnb/mui-datatables/blob/master/examples/serverside-pagination/index.js changing rowsPerPage to 15.
  2. select the first row of the first page.
  3. go to next page.
  4. 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

7sean68 avatar Feb 17 '21 17:02 7sean68

It can be replicated here: https://j8pbp.sse.codesandbox.io/#serverside-pagination

How to reproduce:

  1. Select the first row
  2. Navigate to the next page
  3. The first row in the second page is selected!
  4. Unselect the first row in page 2
  5. Navigate back to the first page
  6. The first row in the first page is unselected!

Mgayar-sci avatar Feb 17 '21 21:02 Mgayar-sci

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;

gthomas2 avatar May 24 '22 12:05 gthomas2

Any fix for workaround for this?

thorep avatar Jan 06 '23 19:01 thorep

I'm also facing that issue - is there a solution yet?

lajanzen avatar Feb 26 '24 09:02 lajanzen