Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Table] reserveSelectedRowOnPaginate=false 时表头全选包含其他页数据

Open Beginner friendly
#4,416 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@dvd233 is already working on this.

Since Oct 6, 2026.

  • #4417 by @dvd233 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
react, typescript
Domain
frontend, testing

Research direction

Start with packages/components/table/hooks/useRowSelect.tsx, especially how the header select handler chooses rows when reserveSelectedRowOnPaginate is false; the issue reports that allTreeRows contains the full data set. Run the provided hook-level reproduction with the listed React test-renderer setup and check that selecting all on a page emits only that page’s keys and selected rows, including after pagination data changes.

Written by the indexing model from the issue text.

Description

🐞 bug
tdesign-react 版本

1.18.4。也核对了当前 develop:d31df33c40a774d435fd00580f72d99f4d271cf0,对应 useRowSelect 源码与发布包 source map 一致。

重现步骤

普通非树形表格,6 条数据,每页 2 条,设置 reserveSelectedRowOnPaginate={false},调用表头全选后,onSelectChange 的 keys 和 selectedRowData 包含全部 6 条数据,而不是当前页的 2 条。

下面是调用发布包原始 hook 和实际表头 onChange handler 的最小复现。它使用 React test-renderer,不是完整 Table DOM 或浏览器交互验证;浏览器回归会另行补充。

在空目录安装并将下方代码保存为 repro.jsx:

npm install --save-exact [email protected] [email protected] [email protected] [email protected] [email protected]
npx esbuild repro.jsx --bundle --platform=node --format=cjs --loader:.css=empty --outfile=repro.cjs
NODE_ENV=test node repro.cjs
import React from 'react';
import TestRenderer, { act } from 'react-test-renderer';
import useRowSelect from 'tdesign-react/es/table/hooks/useRowSelect.js';

const data = Array.from({ length: 6 }, (_, i) => ({ id: i + 1 }));
const column = { colKey: 'row-select', type: 'multiple' };
let selection;
let result;
const props = {
    data,
    columns: [column],
    rowKey: 'id',
    defaultSelectedRowKeys: [],
    pagination: { current: 1, pageSize: 2, total: 6 },
    reserveSelectedRowOnPaginate: false,
    onSelectChange(keys, context) {
      result = { keys, selectedRowData: context.selectedRowData.map(row => row.id) };
    },
};
const classes = { disabled: 'disabled', selected: 'selected', checkCell: 'check' };
function Probe() {
  selection = useRowSelect(props, classes);
  return null;
}
let renderer;
act(() => { renderer = TestRenderer.create(<Probe />); });
console.log('currentPaginateData:', selection.currentPaginateData.map(row => row.id));
act(() => selection.formatToRowSelectColumn(column).title().props.onChange(true));
console.log('onSelectChange:', JSON.stringify(result));
act(() => renderer.unmount());

实际输出:

currentPaginateData: [ 1, 2 ]
onSelectChange: {"keys":[1,2,3,4,5,6],"selectedRowData":[1,2,3,4,5,6]}
期望结果

false 模式下当前页为 [1,2],全选回调的 keys 和 selectedRowData 应仅包含 [1,2]。初始第二页 [3,4] 以及更新当前页数据后也应遵守当前页范围。

当前类型说明 明确说明 false 时全部选中停留在当前页,不跨分页。

实际结果与排查范围
  • 第一页、初始第二页、更新分页数据后的 hook 级复现,均返回全部 6 条数据。
  • true 模式选择所有页、无分页模式选择全部数据、取消全选,这些对照用例保持通过。
  • useRowSelect 中,普通表格的 allTreeRows 仍为完整 data,因此 allTreeRows || currentPaginateData 优先取得完整数据。
  • 本问题只针对 false 的当前页约定,不把 true 模式跨页全选当成错误,也不涉及树形表格的选择语义。
环境

Linux;Node.js 24.19.0;React / react-test-renderer 18.3.1。以上输出为实际运行结果,目前没有浏览器版本或截图可报告。

已查看 FAQ、当前 CHANGELOG、相关问题与开放 PR。调查和复现使用了 AI 辅助;未声称人工或真实浏览器验证。

Dominant language
TypeScript
Stars
967
Forks
376
Avg merge
3d 9h
Merged PRs (30d)
14

Getting set up

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.

More from Tencent/tdesign-react

All issues in Tencent/tdesign-react

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.