TanStack / table

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
https://tanstack.com/table
MIT License
24.49k stars 3.03k forks source link

Table v8 expanding - incorrect state of parent checkbox when selecting subrows #5620

Open odini85 opened 2 weeks ago

odini85 commented 2 weeks ago

TanStack Table version

8.17.3

Framework/Library version

18.2.0

Describe the bug and the steps to reproduce it

The closed issue #4720 has potential bugs.

It can be verified according to the following steps.

1. Apply the code guided in issue #4720 to the sample code below:

https://tanstack.com/table/v8/docs/framework/react/examples/expanding

<IndeterminateCheckbox {...{ checked: row.getIsSelected() || row.getIsAllSubRowsSelected(), indeterminate: row.getIsSomeSelected(), onChange: row.getToggleSelectedHandler(), }} />

2. Implement this guided sample code into the sample code and conduct tests.

3. The potential bugs identified are as follows:

if the parent is checked and all children are checked, unchecking one child does not change the status of the parent checkbox.

https://github.com/TanStack/table/assets/29395995/fb14a72b-cce2-4a38-b3d6-218c00809581

If all children are individually checked, the parent's checkbox status changes to checked. However, if the parent checkbox is then unchecked, it does not uncheck all the children.

https://github.com/TanStack/table/assets/29395995/06470539-9371-43c2-b301-ddfcb178066b

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/devbox/jolly-nightingale-k9tx7h

Screenshots or Videos (Optional)

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct