table
table copied to clipboard
`getGroupedRowModel` doesn't calculate `leafRows` correctly at depth 0
TanStack Table version
8.21.3
Framework/Library version
React v19.0
Describe the bug and the steps to reproduce it
See the implementation here: https://github.com/TanStack/table/blob/9c62cf2024b86c419f7015f963248739bab1b0e7/packages/table-core/src/utils/getGroupedRowModel.ts#L75
// Flatten the leaf rows of the rows in this group
const leafRows = depth
? flattenBy(groupedRows, row => row.subRows)
: groupedRows
The current implementation only calls the flattenBy function for depth > 0. Meanwhile, I believe the purpose of leafRows is to always create the flattened version and thus the flattenBy must always be called unless groupedRows no longer contains any subrows -- need to check groupedRows.some((row) => row.subRows.length > 0) instead of whether depth is falsy.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct
- [x] I agree to follow this project's Code of Conduct
- [x] 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.