TanStack / TanStack/table

Row selection acting strange when using fully controlled table

Open
#4,812 4 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

Describe the bug

When I try to use table row selection with fully controlled state and i'm on the second page, then it selects the first page.

I think it's either the selection function is not accounting for the page index in getToggleAllPageRowsSelectedHandler OR it is re-rendering the page index back to 0.

Your minimal, reproducible example

https://codesandbox.io/s/tanstack-table-fullycontrolled-w-selection-gmuhmm?file=/src/main.tsx:667-702

Steps to reproduce
  1. Go to second, third, or fourth page of table
  2. Click the header selection
  3. See that something did get selected.
  4. Go back to first page and see the first page gets selected.
Expected behavior

As a user I expect to see the page that im on get selected when using the header selection.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

mac OS, chrome, Version 112.0.5615.49 (Official Build) (arm64)

react-table version

8.8.5

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 minimal reproduction in CodeSandbox, especially src/main.tsx around lines 667-702, and reproduce the issue on the second, third, or fourth page. Inspect getToggleAllPageRowsSelectedHandler and the controlled pagination behavior. Done means header selection selects the currently displayed page rather than the first page.

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.