Skip to content

getIsSomeRowsSelected returns a wrong value when unselecting rows manually #5939

Open
@louis-prudhomme

Description

@louis-prudhomme

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions