Skip to content

Table row selection issues when some rows have selection disabled #5060

Closed

Description

@itsmejoeeey

Describe the bug

I've noticed some table issues when some rows have row selection disabled:

  1. Rows that are not selectable prevent row.getIsAllSubRowsSelected() or table.getIsSomeRowsSelected() from returning true even when all selectable rows are selected.
  2. Using row.toggleSelected(..) on an expandable row with selection disabled (but enableSubRowSelection = true) only works to select all sub-rows. Further calls to row.toggleSelected(..) do not de-select the sub-rows.

These issues are making it harder for me to implement custom "cascading" behavior.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/bug-tanstack-table-row-selection-djm542

Steps to reproduce

In the below example selection is disabled for rows:

  • that can expand
  • that are the last child
A B
image image

Reproduction A:

  1. Expand the first row.
  2. Select all sub-rows of the first expanded row.

The parent-row selection checkbox still shows as indeterminate.

Reproduction B:

  1. Expand all parent rows.
  2. Select all sub-rows under all parent rows.

Both the parent-row selection checkboxes, and the header checkboxes still show as indeterminate.

Reproduction C:

  1. Expand the first row.
  2. Click the toggle button next to the parent row.
  3. Click the toggle button again (and again, and again).

Notice that the toggle button fails to deselect the now-selected rows.

Expected behavior

A B
image image

Reproduction A:

The first expandable row checkbox should show as checked.

Reproduction B:

All checkboxes should show as checked.

Reproduction C:

Subsequent clicks of toggle should de-select, and then re-select the sub-rows.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Windows 11
  • Browser: Firefox
  • Version: 117.0

react-table version

8.9.7

TypeScript version

No response

Additional context

I'm in the process of tidying up some changes that address these issues.

I will push these changes and open a PR momentarily.

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. changed the title [-]Table row selection issues when some rows have row selection disabled[/-] [+]Table row selection issues when some rows have selection disabled[/+] on Sep 7, 2023
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