Skip to content

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

Closed

Description

@aleksygoroszko

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.

Activity

  1. aleksygoroszko commented on Feb 21, 2023

    @aleksygoroszko
    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(), }} />

  2. VincEnterprise commented on Apr 5, 2023

    @VincEnterprise

    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
  3. VincEnterprise commented on Apr 5, 2023

    @VincEnterprise

    @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?

  4. wkeese commented on Oct 8, 2025

    @wkeese

    Yes, please reopen this. At the very least, https://tanstack.com/table/latest/docs/framework/react/examples/expanding should be updated to work correctly, but as explained in #4878 this seems like a problem with the library itself rather than a problem with the demo.

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