Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getIsSomeRowsSelected returns a wrong value when unselecting rows manually #5939

Open
2 tasks done
louis-prudhomme opened this issue Feb 28, 2025 · 0 comments
Open
2 tasks done

Comments

@louis-prudhomme
Copy link

louis-prudhomme commented Feb 28, 2025

TanStack Table version

8.20.5

Framework/Library version

18.3.1

Describe the bug and the steps to reproduce it

The row selection state is a Record<string, boolean> (where the key is the row ID). As such, a row is selected if :

  1. a record with key matching the row ID exists in the state
  2. its value is true

The current implementation of the getIsSomeRowsSelected method misses point #2 and only checks for existence of keys in this state.

I'm ready to open a PR for it, but IMHO the problem also comes from using a complicated state structure (a record) in lieu of a regular list (or a Set) (with which the row is selected if its ID is present in the list/set) : the whole selection model would benefit from a refactoring.

In the meantime, it is possible to fallback on the table.getSelectedRowModel().rows.length !== 0 as a workaround.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant