-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TableBody] checkboxes do not reflect new selected state of TableRows (v0.11) #1345
Comments
@rscheuermann Thanks for the details! Part of the problem is reporting the selected rows so some thing needs to know how many rows are selected. We could modify this so that we regenerate the list every time properties change. The changes in #1325 should address this issue or programmatically changing the selected rows. |
@rscheuermann #1325 was merged so I am closing this. Please re-test and if you still experience this issue, let me know -- i'll re-open |
I'm getting this issue in v0.13.4 of material-ui. I have the following table
When I individual select and deselect the rows everything works fine. (On a side note, it would be nice if instead of |
I'm getting the same problem as @That-David-Guy. Here's a gist of my Component:
Select All works fine, and the |
Is there any update on this bug? I'm using v0.15.0 and I still am seeing the issue with the last row not being unchecked when you use the unselect all button. This pretty much renders the select/unselect all feature unusable until it is fixed. |
…ring The initial issue being fixed here was the unselect all button not actually unselecting all of the TableRow checkboxes. This was caused by the TableBody not respecting the value passed in the props for 'selected' when a re-render was caused. Alongside of this, I added checks for the other props that could be passed on the TableRow (hoverable and striped).
I have the same issue. Using 16.6.
|
This may be fixed #5884? |
This is still a reproducible issue in 16.7. It's also apparent when changing the rows. Ex:
|
I'm not entirely sure if this is the same bug, but 16.7 introduced a problem for me. I have two tables that I move data between by clicking on them and using the row key to add/remove array data feeding the tables. This is done through state. As of 16.7, the first click provides the key value to my onRowSelection method, but any following that I receive no value.
Presumably this is due to the change in #5884 but I can't figure out why... |
The way the component is coded currently the description should read...
And it's name should be Changing this value programmatically will not change the state of the tables "selectedRows". The Table component itself would need to provide access to the selectedRows state in order for selection to change. I too need the ability to programmatically change the state of the "selectedRows", but I'm not sure how open to change the owners are on this control. The problem is that you can't change the state of the row itself... you have to change the state of the entire table which means it will need to expensively re-render the entire component... rather than just the row... This is all due to the fact the selectedRows state is stored by the table component itself. I think the smallest footprint solution would be to create a setSelectedRows prop which would allow the developer to pass an array similar to the one stored in the state and simply change the state in the componentWillRecieveProps function which would cause a re-render.... some time passes... writes some code... installs the linter... runs the linter... wonders why eslint hints aren't showing up in sublime anymore... barrels on anyway and DONE. Check out idea here: The optimal solution is to let the row handle "selected" in its' own state instead of the table handling it but.... that would require re-writting the entire table component... and I don't have that kind of time atm 😢 . I'm going to test this spike out in the morning but I'm open to feedback and any ideas... I won't do a pull until one of the maintainers asks... to many dead pull requests experiences in other projects and heartache... |
Good news - it's already been done! https://github.com/callemall/material-ui/tree/next/src/Table |
@mbrookes Is there a way I can already use those updates? Has this been released or is it still work in progress? |
@mbrookes Well that's great news but... the last time I tried to use the next branch I ran into a several issues and figured it wasn't stable enough for use yet. I really hope that it's release ready for my next project but for now I'm planning to stick with this release. Since we still need a fix for the current version I had a chance to test out my spike this morning and the trouble was that the state can be both a string or an array... which the proptype wasn't happy about. So i junked the proptype (which is bad form I know , I know) but it works and at the end of the day thats all I really care about. Dirty working version: master...Cleanshooter:table-rows-not-reflecting-selected-value-prop-value If anyone is interested (or in a pinch like I am) and needs the fix ASAP I have a build of it here: https://github.com/Cleanshooter/material-ui-test used basically in the same way as core but you can pass something like this in: import {TableBody} from 'material-ui-test/Table';
<TableBody
showRowHover
stripedRows
deselectOnClickaway={false}
setSelectedRows={this.state.selected}
> this.state.selected is updated by the "Table" onRowSelection prop/function and in other places manually when I need to pragmatically change which items are selected.. I think the rest is a bit self explanatory on how its used... 😉 |
@apendua you can @Cleanshooter thanks for sharing your fix. |
i tried installing material-ui@next and I get all these errors now...
|
Is it still in WIP? |
We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it. |
I am testing the latest version of Table on the v0.11 branch, which introduces composable Tables (nicely done @jkruder).
Steps To Reproduce the bug:
Expected Behavior: The TableRow for the removed id becomes unchecked.
Action Behavior: The TableRow remains checked.
I've debugged this, and the TableRow's are rendered with selected={false}, accurately. BUT the TableBody is what controls the state of the checkboxes for each row. And the TableBody does not updated its state of selectedRows when receiving new properties. TableBody doesn't look at the new state of it's children TableRows to determine the new state of selectedRows.
My suggestion is to move the rendering of the checkbox into TableRow itself where it knows the state of the "selected" prop.
Any of this making sense? It's a complicated bug, I know.
The text was updated successfully, but these errors were encountered: