[TableBody] Why componentWillReceiveProps set only the last item selected when I deselect an item?
See original GitHub issueThe issue:
- I click on select all checkbox in the header of the table -> all items selected.
- I deselect a random item.
- 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:
- Created 7 years ago
- Reactions:6
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1
@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