-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: assign parentId to subRows when creating aggregatedRows #4882
Conversation
@@ -118,6 +118,10 @@ export function getGroupedRowModel<TData extends RowData>(): ( | |||
}) | |||
|
|||
subRows.forEach(subRow => { | |||
if (!subRow.parentId) { | |||
Object.assign(subRow, { parentId: id }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this also introduces a bug where the table will crash after ungrouping by a column. Needs to be looked into more, but this will be part of the solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch Kevin. I was so focused on the solution for my current use-case that I forgot about ungrouping 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into it, we have to find a way to remove the parentId as we ungroup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to navigate this code, trying to follow the same approach for how the .depth
value is assigned/unassigned.. But I see that property being modified in here:
row.depth = depth |
So, I have couple questions:
- What is the difference between
table/packages/table-core/src/utils/getGroupedRowModel.ts
Lines 38 to 41 in 46b160d
row.depth = depth groupedFlatRows.push(row) groupedRowsById[row.id] = row - Would that better a place to assign/unassign the
parentId
🤔?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what is worth:
assigning/un-assigning depth
in v7 works just fine, here an example: https://codesandbox.io/s/amazing-water-pcepcv?file=/src/App.js
This is still an important bug fix. Will be looking into how to fix the ungrouping crash |
I'm sorry I let this PR stale. Work has been insane last months, that I haven't had the time to work on any of this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To update
@@ -118,6 +118,10 @@ export function getGroupedRowModel<TData extends RowData>(): ( | |||
}) | |||
|
|||
subRows.forEach(subRow => { | |||
if (!subRow.parentId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank for update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To update
Fixes #4881