TanStack / TanStack/table

ColumnGrouping.getDefaultColumnDef should not return aggregatedCell

Open
#5,778 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
28.4k
Forks
3.6k
Avg merge
1d 14h
Merged PRs (30d)
10

Description

TanStack Table version

v8.20.5

Framework/Library version

v18.3.1

Describe the bug and the steps to reproduce it

flexRender(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext()) becomes meaningless because then aggregatedCell is not defined, the default aggregatedCell return from ColumnGrouping.getDefaultColumnDef is used.

  1. Open the following CodeSandbox
  2. Click status to group status column
  3. Profile Progress show 49.995466826778745, expected to be Profile Progress show 50%

Temporal solution: use null or undefined:

{
                accessorKey: 'progress',
                header: 'Profile Progress',
                cell: ({ getValue }) =>
                  Math.round(getValue<number>() * 100) / 100 + '%',
                aggregationFn: 'mean',
                aggregatedCell: null,
                // aggregatedCell: ({ getValue }) =>
                //   Math.round(getValue<number>() * 100) / 100 + '%',
}

or

    defaultColumn:{
       aggregatedCell: undefined,
     }

but it looks weird and unnecessary.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/devbox/github/tanstack/table/tree/main/examples/react/grouping?embed=1&theme=dark

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked React grouping CodeSandbox and trace ColumnGrouping.getDefaultColumnDef alongside the flexRender call described in the report. Reproduce the grouped progress display, then verify that the expected 50% formatting is preserved without explicitly setting aggregatedCell.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.