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

[TableRow] does NOT remain select when showing Drawer on TableRow select

Open davidruisinger opened this issue 10 years ago • 10 comments

Problem description

I have a table where I show some items and a click on the item reveals a Drawer with the item details. Unfortunately the selected row instantly get's deselected when the Drawer ist shown.

Steps to reproduce

  1. Create a Table with selectable={true} and onRowSelection={myOnSelectFunction}
  2. I also added deselectOnClickaway={false} to TableBody
  3. In the myOnSelectFunction show a Drawer ==> Drawer is shown BUT selected Row gets deselected right away

Expected behavior

... ==> Drawer is shown AND selected row remains selected. (So I can update the details if another item is selected or deselect the row when Drawer is dismissed)

Versions

  • Material-UI: "0.15.2"
  • React: "15.2.1"
  • Browser: Chrome 51.0.2704.103

davidruisinger avatar Jul 18 '16 12:07 davidruisinger

I am also facing same issue. If you don't do any state update in callback function, it stays selected. But if we change state, then selection is unchecked.

debslab avatar Jul 19 '16 10:07 debslab

Facing the same issue, as described above.

siegesmund avatar Aug 29 '16 18:08 siegesmund

I'm seeing something similar. If I have any onRowSelection callback defined and I do anything like modifying state in the callback then the row is not selected, but the callback is fired. The row is selected if I click on it again.

dotnwat avatar Oct 28 '16 23:10 dotnwat

This is also true if you dispatch an action through Redux and modify some completely unrelated state which shouldn't be of any interest to the table (because, frankly, I didn't write the code yet which uses that state).

Also: This worked in 0.15.1

Rhywden avatar Dec 11 '16 20:12 Rhywden

Okay: Follow-up: ANY kind of state change will reset the table. Even when said state change is done by completely unrelated components and does not change the UI at all

This makes the Table completely unusable.

Rhywden avatar Dec 11 '16 21:12 Rhywden

Also: The SelectAll is not affected by this. If I hit SelectAll and then change the state, all rows will stay selected.

Rhywden avatar Dec 11 '16 21:12 Rhywden

Okay, figured it out, at least for me: You must isolate the table completely and utterly into its own component. Then you only pass static props into this component.

Because as soon as one of those props changes, even if it isn't anywhere near related to anything the table uses and even if the prop doesn't actually change anything in the UI, your table will reset.

Rhywden avatar Dec 11 '16 22:12 Rhywden

Ah I have the same issue. As soon as I try to do something in the onRowSelected callback the row gets unselected. If I do nothing in the callback it all works fine.

rachel-singh avatar Dec 21 '16 17:12 rachel-singh

Again: Isolate the table thus that the table state is not changed through the selection. I.e. you need to use something like Redux to notify other components of table changes.

Rhywden avatar Dec 21 '16 18:12 Rhywden

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. Still, we will accept PR fixes until v1-beta takes over the master branch.

oliviertassinari avatar Jul 28 '17 20:07 oliviertassinari