question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TableBody] Why componentWillReceiveProps set only the last item selected when I deselect an item?

See original GitHub issue

The issue:

  1. I click on select all checkbox in the header of the table -> all items selected.
  2. I deselect a random item.
  3. All the items deselected in the table except the last one.

I found the following code in table-body.js / componentWillReceiveProps:

if (this.props.allRowsSelected && !nextProps.allRowsSelected) {
      newState.selectedRows = this.state.selectedRows.length > 0 ? [this.state.selectedRows[this.state.selectedRows.length - 1]] : [];
} else {
     newState.selectedRows = this._calculatePreselectedRows(nextProps);
}

What is the purpose of [this.state.selectedRows[this.state.selectedRows.length - 1]]? Why should deselect all items but the last one when select all was checked before? If I remove the true branch it works as expected: the clicked item and the select all checkbox in header becomes unchecked.

Versions

Material-UI: 0.15.0-alpha2 & 0.14.4 React: 0.14.8 Browser: Chrome (49.0.2623.112 m)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Jul 28, 2016

+1

0reactions
aahan96commented, Aug 16, 2016

@akosk: @nathanmarks is working on the 0.16.0 release, which will address many issues with the table component. Have a look at issue #2251. I think we can close this issue for now as it’s being addressed in the new release

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TableBody] Why componentWillReceiveProps set ... - GitHub
The issue: I click on select all checkbox in the header of the table -> all items selected. I deselect a random item....
Read more >
'componentWillReceiveProps' clearing Dropdown Selected ...
I am currently having a problem with the States Dropdown, which recieves a countryId value from state that is set when a item...
Read more >
Udacity React Fundamentals - James Priest CV
The difference is that the function passed to .filter() is used as a test, and only items in the array that pass the...
Read more >
You Probably Don't Need Derived State – React Blog
A common misconception is that getDerivedStateFromProps and componentWillReceiveProps are only called when props “change”. These lifecycles are ...
Read more >
ميډياويکي:Vector-opt-out - ويکيپېډيا
getOwnPropertySymbols; var hasOwnProperty = Object.prototype. ... When an interaction goes out of scope, the previous set (if any) is restored. var ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found