You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
row selection not working for nested rows (getSubRows) #4878
✅ Notice all rows (parent and children) are selected
Unselect the first sub-row of the expanded group
🛑 Notice the parent row checkbox is stuck on "checked", when it should be "indeterminate"
Expected behavior
As a user, I expected the parent row to react to the row-selection status of its children, regardless on how they are selected/unselected:
some sub-rows selected: parent row "indeterminate"
no sub-rows selected: parent row "unchecked"
all sub-rows selected: parent row "checked"
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Browser: N/A
OS: N/A
Happens in codesandbox
react-table version
v8.9.1
TypeScript version
N/A - whatever codesandbox uses
Additional context
No response
Terms & Code of Conduct
I agree to follow this project's Code of Conduct
I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Any updates on this issue?
I'm planning to update from v7 -> v8 because v7 has a bug with isSomeSelected prop for nested rows, but looks like updating does not make any sense because a v8 still has a problem with checkboxes for nested rows...
This is a great fix since the issue is still occurring, thank you! I noticed that the table.getIsSomeRowsSelected() handler isn't counting grouped rows that are being selected, so to fix this I fixed up a function you can use to check if any are selected in the grouped or subrows, hope it helps someone like it did for me.
function getIsAnyRowsSelected(table: Table<any>) {
const rows = table.getExpandedRowModel().rows;
const { rowSelection } = table.getState();
let isAnyRowsSelected = rows.some(row => {
if (rowSelection[row.id]) return true;
if (row.subRows.some(subRow => rowSelection[subRow.id])) return true;
return false;
});
return isAnyRowsSelected;
}
With the above proposal, selecting all of the children and therefore making the parent row selected, then the parent row can never be a selectable element. There is no independence between parent and children. The opposite would be true too (deselecting all of the children will automatically deselect its parent).
Provided solution sometimes leaves parent row selected in the state when not all its children have been selected. This leads to the parent row checkbox being unresponsive
Activity
VincEnterprise commentedon May 30, 2023
Also see: #4720
@tannerlinsley could you please take a look at this 🥹🙏
I really want to use tabstack table for a project but this specific issue is preventing me from being able to use it.
This naive UI example here (cascade checking) has the behavior we are expecting:
https://www.naiveui.com/en-US/os-theme/components/tree#cascade.vue
VincEnterprise commentedon Jun 7, 2023
bump
artem-zaiko-yara commentedon Jun 14, 2023
I use this workaround until the bug is fixed (React):
R-Bower commentedon Jan 27, 2024
Link to fix:
#3965 (comment)
Profesor08 commentedon Jan 30, 2024
bump, issue is actual
Current workaround is to toggle manually
VACincoming commentedon Feb 10, 2024
Any updates on this issue?
I'm planning to update from v7 -> v8 because v7 has a bug with
isSomeSelectedprop for nested rows, but looks like updating does not make any sense because a v8 still has a problem with checkboxes for nested rows...#3965
pelletier197 commentedon Feb 28, 2024
Just noticed the same issue 👍
Macs89 commentedon Mar 20, 2024
Yep, I've run into this issue too.
minhdtb-tanaakk commentedon Mar 27, 2024
same issue here
cthomesmatt commentedon Apr 3, 2024
This is a great fix since the issue is still occurring, thank you! I noticed that the table.getIsSomeRowsSelected() handler isn't counting grouped rows that are being selected, so to fix this I fixed up a function you can use to check if any are selected in the grouped or subrows, hope it helps someone like it did for me.
vladcos commentedon Apr 17, 2024
same issue
mttigg commentedon May 8, 2024
Following this issue.
xuyunan commentedon May 30, 2024
same issue
etiennecoyacabelio commentedon Jul 18, 2024
same issue
thescripted commentedon Oct 11, 2024
I'm curious what makes this a bug?
With the above proposal, selecting all of the children and therefore making the parent row selected, then the parent row can never be a selectable element. There is no independence between parent and children. The opposite would be true too (deselecting all of the children will automatically deselect its parent).
TsengTofu commentedon Jan 21, 2025
follow this.
ahmedprusevic commentedon Jun 8, 2025
+1
Rushour0 commentedon Sep 8, 2025
bump here
Radomir-Drukh commentedon Oct 14, 2025
Update: contains bugs, do not use
Provided solution sometimes leaves parent row selected in the state when not all its children have been selected. This leads to the parent row checkbox being unresponsiveHere is an improved solution as a custom hook:Old code
Radomir-Drukh commentedon Nov 10, 2025
Here is revised solution
fix: honor selection rules in select-all paths, add deselectParents o…