Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

csantos1113
Copy link

Fixes #4881

@@ -118,6 +118,10 @@ export function getGroupedRowModel<TData extends RowData>(): (
})

subRows.forEach(subRow => {
if (!subRow.parentId) {
Object.assign(subRow, { parentId: id });
Copy link
Member

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.

Copy link
Author

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 😢

Copy link
Member

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.

Copy link
Author

@csantos1113 csantos1113 May 27, 2023

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:

So, I have couple questions:

  1. What is the difference between
    row.depth = depth
    groupedFlatRows.push(row)
    groupedRowsById[row.id] = row
    and the section I touched on this PR? mostly, they seem the same, but not sure why they happen in two diff places
  2. Would that better a place to assign/unassign the parentId 🤔?

Copy link
Author

@csantos1113 csantos1113 May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞 well, depth is also wrong

ungrouping the column keeps the rows depth: 1; 🛑

image

but they should go back to depth: 0 which is the expected value when ungrouped 🤕

image

Copy link
Author

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

@KevinVandy
Copy link
Member

This is still an important bug fix. Will be looking into how to fix the ungrouping crash

@csantos1113
Copy link
Author

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

Copy link

@chatpong-v chatpong-v left a 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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for update

Copy link

@chatpong-v chatpong-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parentId or getParentRow is undefined for grouped data (flat data + grouping column)
3 participants