Skip to content

Expanding API including rows that dont include a subRow #6115

@RichardHpa

Description

@RichardHpa

TanStack Table version

8.21.3

Framework/Library version

17.0.1

Describe the bug and the steps to reproduce it

While using the expanding api within tanstack table, I noticed that the expanding doesn't take into consideration rows that don't have subrows.

This is only obvious when you open all rows (in my example I have set the initial expanded state to true) and then close just 1 row. If you have a look at the expanded state, it now includes every row's index, including the ones that don't have subrows.

To show this I have used the default expandable example and made a few edits but the main change is I have made it that only even numbered rows have subrows.

Steps to reproduce

  1. View this sandbox. Everything should be open and the expanded state is true
  2. Close the 2nd row. This should now generate the expanded state. And you should see that both 0 and 3 are now true, which shouldn't even better in the object as those aren't rows that can expand.

This also happens for deep nested rows which means your .getExpandedDepth() is actually incorrect as its giving you a max depth that isn't actually possible.

Steps to reproduce this other issue

  1. View this sandbox. Everything should be open and the expanded state is true
  2. Close every expandable row individually. Even though all the rows should be uncollapsed now. The expanded state still includes entries but all of them are invalid entires as their rows dont have sub rows.

I would expect those keys to not be in the object as they dont have a sub row

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://stackblitz.com/edit/tanstack-table-3zzzyjrn?file=src%2Fmain.tsx

Screenshots or Videos (Optional)

Image Image

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

Yes, I am also opening a PR that solves the problem along side this issue

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.

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