Skip to content

[Bug] useRowSelect and useTable#getSubRows does not work as expected #2609

@michael-land

Description

@michael-land

Describe the bug (required)

TLDR; When getRows defined, subRows are not get selected when parent selected.

Looking into the src code, https://github.com/tannerlinsley/react-table/blob/master/src/plugin-hooks/useRowSelect.js#L170
useSelected retrieve subRows using getSubRow(), it pass the row instance instead of row original data. Which cause the problem.

I think we are safe to use row.subRows here since subRows already computed inside useTable https://github.com/tannerlinsley/react-table/blob/master/src/hooks/useTable.js#L549-L558

image

Provide an example via Codesandbox! (required)
https://codesandbox.io/s/priceless-currying-5mwss?file=/src/App.js

Steps To Reproduce (required)
Steps to reproduce the behavior:

  1. Go to
  2. Click on first row
  3. Click on expand

Expected behavior (Recommended)
All sub rows should get selected

Additional context
Add any other context about the problem here.

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