Skip to content

row.getToggleExpandedHandler() handler doesn't work #4940

@wallpants

Description

@wallpants

Describe the bug

When defining a cell that contains a button with:

<button onClick={row.getToggleExpandedHandler()}>
  {row.getIsExpanded() ? "collapse" : "expand"}
</button>

the handler does not change the expanded status.

If we instead do:

<button onClick={() => row.toggleExpanded()}>
  {row.getIsExpanded() ? "collapse" : "expand"}
</button>

the expanded status is correctly updated.

If I try the same this with row.getToggleSelectedHandler(), it works as expected when trying to update selected status.

Your minimal, reproducible example

https://stackblitz.com/edit/stackblitz-starters-fndwe1?file=src%2FApp.tsx

Steps to reproduce

  1. Click on the row's "expand" button. Row will not be expanded.

Expected behavior

Assigning row.getToggleExpandedHandler() to the onClick attribute of a button should make that button handle expanded state.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

macOS: firefox, edge
fedora: firefox, edge

react-table version

V8.9.3

TypeScript version

No response

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.

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