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

Issue with getIsSomeRowsSelected when using grouping #5700

Open
2 tasks done
josueuitzil opened this issue Aug 8, 2024 · 0 comments
Open
2 tasks done

Issue with getIsSomeRowsSelected when using grouping #5700

josueuitzil opened this issue Aug 8, 2024 · 0 comments

Comments

@josueuitzil
Copy link

josueuitzil commented Aug 8, 2024

TanStack Table version

v8.20.1

Framework/Library version

React 18.3.1

Describe the bug and the steps to reproduce it

The return value of table.getIsSomeRowsSelected is inconsistent when using the grouping feature, sometimes returning an erroneous value. Might be related to #4878
I think this issue might be caused by the grouped row being considered in the selected state object of the table, even if it not a "real" row coming from the dataset. The getIsSomeRowsSelected function checks if the total number of rows selected is less than the flat rows of the filtered row model. Flat rows only returns rows included in the dataset, grouped columns are not part of this array.

imagen

However, since the selection state is including the "fictional" gruped columns it becomes possible for the totalSelected variable to be greater than the flatRows length.

imagen

Maybe grouped columns should not be considered for the selected state, since they are not items in the data array. Clicking on it should toggle subrows without including the grouped column in the state.

Steps to reproduce

  1. Go to https://codesandbox.io/p/devbox/tanstack-grouping-and-selection-4kyzxd?workspaceId=a99c66fb-3472-4189-a44e-72c9121d3c0a
  2. Change the displayed rows to 50 to make testing easier
  3. Click on the fist icon on the Status column to group
  4. Click on the checkbox of the first grouped row to select all its children
  5. Expand other groups and select the other subrows one by one; do not select using the grouped parent row
  6. Notice that at some point the header checkbox gets unchecked instead of being indetermined
imagen

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/devbox/tanstack-grouping-and-selection-4kyzxd?workspaceId=a99c66fb-3472-4189-a44e-72c9121d3c0a

Screenshots or Videos (Optional)

Screen.Recording.2024-08-08.at.12.08.20.p.m.mp4

Do you intend to try to help solve this bug with your own PR?

Maybe, I'll investigate and start debugging

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