state 'expanded' set in useControlledState prevents toggling
See original GitHub issueDescribe the bug Version: 7.0.0-beta.27
I implemented a tree table and it should be initially expanded to a specific path.
When setting the expand
state with the useControlledState
option, it’s not possible to collapse or expand the rows anymore. As an alternative I tried to use the initialState.expanded
option, but the initial state resets, when the data is updated.
To Reproduce Steps to reproduce the behavior:
I replicated both of the problems in a codesandbox
useControlledState
example: https://codesandbox.io/s/sparkling-dust-cc8ny (App.js
, line:37-46, 59)
- Add
useControlledState
option to Table options and set theexpanded
state.
initialState
example: https://codesandbox.io/s/busy-cherry-mvlhj (App.js
, line: 48, 153-161)
- Add
initialState: { expanded: ["0", "0.0"] }
to table options - Add a timeout to simulate data loading
Expected behavior It should be possible to initially expand rows and still be able to expand/collapse them.
Desktop (please complete the following information):
- OS: iOS
- Browser: chrome
- Version 78.0.3904.108
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
I’m also having issues with this. If I use the useControlledState option for expanded rows, I can persist the expanded state when the data updates, but have to wait for a re-render (as documented) for the expansion to happen rather than having the toggle action trigger the re-render. Using websockets for data updates, redux/reselect for state management, and react-table v7.3.2 with filtering / sorting / expanding rows / subComponents / editable cells all enabled. When new data comes in, I don’t want the current sort / filter / expanded rows to reset, only the applicable data to be updated.
Is there an actual working example of the FAQ referenced being implemented? It doesn’t appear to work at present.
Is it possible to have useControlledState to control the “expanded” key and toggling both working together? Once I set the expanded key in ControlledState then those toggling doesn’t work just like @Lukas742 mentioned. Is it expected?