Skip to content

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

Description

@tmax22

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions