table icon indicating copy to clipboard operation
table copied to clipboard

Row selection acting strange when using fully controlled table

Open changyeamoon opened this issue 1 year ago • 4 comments

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

  • [X] I agree to follow this project's Code of Conduct
  • [X] 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.

changyeamoon avatar Apr 14 '23 01:04 changyeamoon

@tannerlinsley bump?

changyeamoon avatar Apr 19 '23 16:04 changyeamoon

I agree that it is a bug.

talatkuyuk avatar Apr 25 '23 19:04 talatkuyuk

@talatkuyuk any updates on this? https://github.com/TanStack/table/issues/4848 looks like the solution

changyeamoon avatar Oct 24 '23 01:10 changyeamoon

Yup, as @changyeamoon mentioned. Using getRowId in table config sets given property as value which by rows will be managed. Any unike value will do so, it's not a bug it's a feature in my humble opionion :)

plmiso avatar Nov 29 '23 07:11 plmiso