rowExpandable does not work when dataSource has children field

オープン
#1,416 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
react, typescript
領域
frontend

調査の方向性

Table のエントリーポイントから開始し、レコードに children が含まれている場合に expandable.rowExpandable がどのように処理されるかを追跡します。children 配列が 1 つは要素あり、もう 1 つは空の例を再現し、その後、最初の行だけに展開アイコンが表示され、tree モードで rowExpandable が呼び出されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Description
When using rc-table with tree data structure (when dataSource contains children field), the rowExpandable configuration is completely ignored. This prevents developers from controlling which rows should be expandable based on custom logic.

Current Behavior
When dataSource contains children field, the table automatically enables tree mode

In tree mode, the presence of children field alone determines expandability, regardless of its content

Empty children arrays ([]) still show expand icons

The rowExpandable function is never called or its return value is ignored

Expected Behavior
rowExpandable should work consistently regardless of whether the table is in tree mode or not

Developers should be able to control expandability using custom logic even when children field exists

When rowExpandable returns false for a row, it should not show expand icon regardless of children field

import { Table } from 'rc-table';

const dataSource = [
  {
    key: '1',
    name: 'Parent 1',
    children: [
      { key: '1-1', name: 'Child 1-1' },
    ],
  },
  {
    key: '2',
    name: 'Parent 2',
    children: [], // Empty children - should not be expandable
  },
];

const columns = [
  {
    title: 'Name',
    dataIndex: 'name',
    key: 'name',
  },
];

const App = () => (
  <Table
    dataSource={dataSource}
    columns={columns}
    expandable={{
      // This is ignored because children field exists
      rowExpandable: (record) => 
        record.children && record.children.length > 0
    }}
  />
);

In this example, both rows show expand icons, but the second row should not be expandable since its children array is empty.

主要言語
TypeScript
スター
1.4k
フォーク
618
平均マージ
10時間 19分
マージ済み PR(30日)
2

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

react-component/table のほかの issue

react-component/table の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。