react-component / react-component/table

[bug] Quickly expanding several lines with a custom asychronous ExpandIcon onExpand call results in only one line expansion open

Open
#961 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.4k
Forks
618
Avg merge
10h 19m
Merged PRs (30d)
2

Description

Custom ExpandIcon quick expansion

How to reproduce

  1. Open the below code sandbox, or copy the below provided code into a project: CodeSandbox
  2. Open several rows in less than one second

Expected behavior: All the rows that have been clicked open and stay open

Actual behavior: The rows open, but close whenever another open and at the end, only one is open

This only happens when the clicking is done faster than the delay after which onExpand is called

Note:

  • The code sandbox uses the following versions: "antd": "5.2.3", "react": "18.2.0"
  • The problem has also been experienced with Ant Design 4.22.7, and React 17.0.2

App.jsx

I copy the code here in case the codesandbox is inaccessible or lost somehow.

import { Table } from "antd";
import "./styles.css";

export default function App() {
  return (
    <div className="App">
      <h1>Hello Ant Design rc-table</h1>
      <Table
        columns={[{ dataIndex: "key" }]}
        dataSource={[{ key: "bamboo" }, { key: "oak" }, { key: "cinnamon" }]}
        expandable={{
          expandedRowRender: (record) => <span>row-content-{record.key}</span>,
          expandIcon: ({ onExpand, expanded, record }) => {
            return (
              <button
                onClick={() => {
                  setTimeout(() => onExpand(record), 1000);
                }}
              >
                {expanded ? "-" : "+"}
              </button>
            );
          }
        }}
      />
    </div>
  );
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the App.jsx reproduction in the issue or open the linked CodeSandbox, then trace the Table expandable flow involving the custom expandIcon and delayed onExpand callback. Done means rapidly clicking several rows with the one-second delay leaves every clicked row expanded, rather than only the last one.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.