carbon icon indicating copy to clipboard operation
carbon copied to clipboard

[Bug]: Expand all toggleBtn doesn't reflect a state change when using pagination

Open esalas012 opened this issue 1 year ago • 1 comments

Package

@carbon/react

Browser

Chrome

Package version

v1.6.0

React version

v17.0.2

Description

I am running into an issue using datatables, pagination and expand all feature(toggle btn). I recently added enableToggle and getExpandHeaderProps to the TableExpandHeader component . However, this doesn't seem to work well with pagination. If I expand all collapsed items and go to a different page, the togglebtn keeps the previous state but all the items are collapsed.

Reproduction/example

https://codesandbox.io/s/keen-wind-7694jj?file=/src/App.js

Steps to reproduce

Click on expand all (togglebtn) and then click on next page. You will notice that all the items are collapsed however, the toggleBtn kept the same state as before.

Code of Conduct

esalas012 avatar Jul 27 '22 20:07 esalas012

Thanks for reporting this, it looks like the internal "expand all" state of DataTable is stale when rows are updated.

For now a workaround I'd suggest is to place a key on the DataTable and regenerate it when the page is changed.

tay1orjones avatar Aug 08 '22 15:08 tay1orjones