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

onSelectionChange looses checkboxes seelcted if .setState() used

Open skitsanos opened this issue 7 years ago • 17 comments

So in my case i needed to take an array of selected items and put them into my component state:

 onSelectionChange={(selection, current) =>
                     {
                       _this.setState({selectedRows: selection});
                     }}

I can see in tableRef.current that tableData marked as checked, but i don't see any checkboxes checked anymore. if i don't do anything with state within this handler, everything works as expected.

Any hints on how to fix it?

skitsanos avatar Nov 08 '19 11:11 skitsanos

Hi @skitsanos ,

I solved the problem. It is related with new componentDidUpdate implementation. This problem will be with next release (probably tomorrow or weekend).

mbrn avatar Nov 08 '19 12:11 mbrn

Tesekkur ederim Mehmet! can't wait :)

skitsanos avatar Nov 08 '19 12:11 skitsanos

This is done with 1.54.1

mbrn avatar Nov 08 '19 20:11 mbrn

I just upgraded to 1.54.1 and it still seems to be a problem for me :/

roseak avatar Nov 13 '19 22:11 roseak

It also changes it so that the selection is just the most current selection instead of including the other options that have also been checked.

roseak avatar Nov 13 '19 23:11 roseak

I'm having the same issue. Even with the latest update, as soon as I call setState, the table re-renders without displaying the selected table rows

andrewmirs avatar Dec 05 '19 18:12 andrewmirs

Any update for this bug? I am still experiencing this on 1.54.1

jasonvooo avatar Dec 12 '19 02:12 jasonvooo

i am still experiencing this issue

KPpuria avatar Dec 17 '19 09:12 KPpuria

Does anyone know when this bug appeared? Is there a previous version where this isn't an issue?

eoghanmccarthy avatar Jan 02 '20 18:01 eoghanmccarthy

It also happens when you try to set state from within options.selectionProps.

eoghanmccarthy avatar Jan 02 '20 18:01 eoghanmccarthy

Same Issue Here, any sort of setState, and the table looses it's state

aniesshsethh avatar Jan 09 '20 15:01 aniesshsethh

@aniesshsethh I created my own checkboxes in a custom column and save the checked state in component state. It's not ideal but works.

eoghanmccarthy avatar Jan 09 '20 15:01 eoghanmccarthy

I do not need for the checkboxes, but to maintain the number of rows shown. so if the user has selected 20, I want 20 selected

aniesshsethh avatar Jan 09 '20 16:01 aniesshsethh

I'm also still experiencing this issue.

Discartyptics avatar Jan 21 '20 21:01 Discartyptics

I am also experiencing this issue. When I call setState from my actions onclick event the table is re-rendered and I lose my selected rows

nocoli avatar Jan 24 '20 04:01 nocoli

Still seeing this as well.

watchsteve avatar Feb 13 '20 00:02 watchsteve

This is still happening here

Laferu avatar Feb 20 '20 16:02 Laferu