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

cell.getIsAggregated should not check for zero length subrows #5605

Open
2 tasks done
tmax22 opened this issue Jun 15, 2024 · 2 comments
Open
2 tasks done

cell.getIsAggregated should not check for zero length subrows #5605

tmax22 opened this issue Jun 15, 2024 · 2 comments

Comments

@tmax22
Copy link

tmax22 commented Jun 15, 2024

TanStack Table version

table-core v8.17.3

Framework/Library version

react

Describe the bug and the steps to reproduce it

current implementation for cell.getIsAggregated is

!cell.getIsGrouped() && !cell.getIsPlaceholder() && !!row.subRows?.length

i would argue that row.subRows?.length is not supposed to be there.

look:

image

as we can see, aggregated cells exists even if no subrows exists for this group. this happens on custom getGroupedRowModel that i implement that makes sure that certain grouping values always exists even if there is no current rows for them(full explanation).

this is not a bug, but rather would say unexpected behavior for the method cell.getIsAggregated. i would argue that at least the next major release should change this behavior.

in my case, checking for row.depth === 0 instead is enough:

const customIsAggregated = !cell.getIsGrouped() && !cell.getIsPlaceholder() && row.depth === 0;
  let renderedCellValue =
    customIsAggregated && columnDef.AggregatedCell
...

image

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

  • 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.
@KevinVandy
Copy link
Member

so like a cell.getIsAggregationCell and similar APIs?

@tmax22
Copy link
Author

tmax22 commented Jun 30, 2024

If you are suggesting adding new api cell.getIsAggregationCell, so yeah, possibly.
But when when you would want to use cell.getIsAggregated?

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

No branches or pull requests

2 participants