material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Wrong row getting selected with onSelectionChange.

Open devat19 opened this issue 7 years ago • 4 comments

Describe the bug I am using pageSize: 20 for pagination; on going to second page(that is from row 21), if try to select a row, the visual effect of checkbox selection is not happening and if i try to select row 1 from second page (that is row 21 in actual table ) row 1(from actual table ) is getting selected instead of 21(from page 1).

To Reproduce My code- onSelectionChange={data => this.selectionChanged(data)} selectionChanged = data => { console.log(data); let jobs = []; let count = 0; this.setState({ checked: true });

data.forEach((element, index, array) => {
  count++;
  jobs.push(element._id);
  if (count === array.length) {
    this.setState({ JobId: jobs }, () => console.log(this.state.JobId));
    console.log(jobs, "ids");
    console.log(array.length);
  }
});

};

Expected behavior I expected correct rows to be selected.

Desktop (please complete the following information):

  • OS: [Linux]
  • Browser [chrome]

Additional context Is this related to calling setState in OnSelectionchange? If yes, what could be the possible alternatives?

devat19 avatar Apr 30 '19 12:04 devat19

Hi @uplsaurabhA ,

Which version do you use? I tested it in latest version and it seems working properly.

mbrn avatar May 02 '19 05:05 mbrn

1.17.0

devat19 avatar May 02 '19 05:05 devat19

Latest version is 1.34.1 now :). I fixed it on previous version.

mbrn avatar May 02 '19 05:05 mbrn

Thanks, issue resolved after updating.

devat19 avatar May 02 '19 06:05 devat19