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
25.23k stars 3.08k forks source link

Function getIsSomeSelected() return false when has one child #5800

Open wellingtonngallo opened 3 days ago

wellingtonngallo commented 3 days ago

TanStack Table version

8.20.5

Framework/Library version

React 17.0.2

Describe the bug and the steps to reproduce it

Description bug

When a parent has only one node and this node is selected, function getIsSomeSelected() return all as false

Additional

See that in my object, subRow has only one item, the problem only occurs in this case. If you add one more item totaling 2 children, it works correctly

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/devbox/clhnxy?migrateFrom=yldcnv

Screenshots or Videos (Optional)

Image

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

None

Terms & Code of Conduct

tuliooov commented 3 days ago

I've also experienced this problem

remleduff commented 2 days ago

My impression is that getIsSomeSelected returns false for any number of subrows if they are all selected. (getIsAllSubRowsSelected() returns true in this case).

You should be able to do row.getIsSomeSelected() || row.getIsAllSubRowsSelected() to get what you want, I think?

I've asked in discord whether adding a row.getIsAnySubRowsSelected() would be accepted.