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

Table v8 expanding - incorrect state of parent checkbox when selecting subrows #4720

Closed
2 tasks done
aleksygoroszko opened this issue Feb 21, 2023 · 3 comments
Closed
2 tasks done

Comments

@aleksygoroszko
Copy link

Describe the bug

When selecting subrows the parent checkbox does not get correct state

Your minimal, reproducible example

https://codesandbox.io/s/github/tanstack/table/tree/main/examples/react/expanding

Steps to reproduce

The bug can be reproduced in official demo:
https://codesandbox.io/s/github/tanstack/table/tree/main/examples/react/expanding

How to reproduce:

  1. Expand the row
    1

  2. Begin selecting subrows, the parent checkbox shows partial selection, which is correct
    2

  3. When selecting last subrow, the parent row is set as unchecked, but should be checked to mark that all subrows are selected.
    3

Selecting/unselecting parent checkox selects/unselects all subrows correctly

Expected behavior

Selecting all subrows must mark parent checkbox as checked

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Windows, Chrome 110.0.5481.104

react-table version

8.7.9

TypeScript version

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.
@aleksygoroszko
Copy link
Author

I haven't considered that maybe the demo itself could be not correct. It looks that it is it's definition of IndeterminateCheckbox doesn't handle more depths so it should be added || row.getIsAllSubRowsSelected() to mark correct checked state:

<IndeterminateCheckbox {...{ checked: row.getIsSelected() || row.getIsAllSubRowsSelected(), indeterminate: row.getIsSomeSelected(), onChange: row.getToggleSelectedHandler(), }} />

@VincEnterprise
Copy link

VincEnterprise commented Apr 5, 2023

I still have trouble with this exact same problem, currently trying to implement this on a Vue project but it's not working.

Here's my attempt:

https://codesandbox.io/p/sandbox/amazing-panna-ksdmvb?file=%2Fsrc%2FApp.vue&selection=%5B%7B%22endColumn%22%3A13%2C%22endLineNumber%22%3A89%2C%22startColumn%22%3A13%2C%22startLineNumber%22%3A89%7D%5D

Everything seems to work except the sub title checkbox.

Repro:

  1. Select both 'nested title' checkboxe
  2. See that the sub title goes to indeterminate state
  3. The main title checkbox however doesn't go to indeterminate state

@VincEnterprise
Copy link

@aleksygoroszko When I apply your changes to the codesandbox demo, the checkboxes still don't work properly.

Maybe this issue needs to be re-opened?

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

2 participants