TanStack / TanStack/table

When sorting on date grouped column of year is not taken into account

Open
#4,628 1 comment 3 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

Describe the bug

I dont know if this is a bug or changed behaviour since v7.

  1. I have a data object value 'caseDate' which is used as row.caseDate.slice(-4) to get the year for the 'year' column.
  2. I have a date column where the same caseDate is formatted as a pretty date and parsed to getTime for sorting in accessorFn.
  3. I have the 'year' column grouped.
  4. If I use the 'date 'column as a default sorting the 'year' grouped column is just sorted as the data comes in instead of also sorted by date because it also uses caseDate. In v7 this was the case and would also order the grouped column.
Your minimal, reproducible example

https://codesandbox.io/s/optimistic-rhodes-2bbzse?file=/src/main.tsx

Steps to reproduce

Just see how the year column is not sorted as the date column.

Expected behavior

I would expect this to work the same as in v7 or a clear explanation why this logic has changed.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Chrome MacOs

react-table version

v8.7.4

TypeScript version

No response

Additional context

No response

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 CodeSandbox, especially src/main.tsx, and reproduce the grouped-year sorting behavior using TanStack Table v8.7.4. Compare the date column's sorting with the grouped year column and inspect the relevant sorting and grouping entry points. Done means the reproduction sorts grouped years consistently with the date column, or the changed behavior is clearly documented.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.