Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Table] pagination 使用三元符并且data为空时,页面会展示之前数据的前十条数据 #2957

Closed
jacksonjin opened this issue Jun 19, 2024 · 5 comments
Labels
🐞 bug Something isn't working

Comments

@jacksonjin
Copy link

jacksonjin commented Jun 19, 2024

tdesign-react 版本

1.7.5

重现链接

https://codesandbox.io/p/sandbox/tdesign-react-demo-forked-r8ptn6?file=%2Fsrc%2Fdemo.jsx%3A1%2C1-38%2C1

重现步骤

重现代码关键是, pagination 是否是三元判断,如果pagination = {total,defaultPageSize, defaultCurrent},就不会出现问题
import React, { useState, useEffect } from "react";
import { Table } from "tdesign-react";

export default function EditableCellTable() {
const arr = Array.from({ length: 100 }, (_, index) => ({ id: index + 1 }));

const [data, setData] = useState(arr);

useEffect(() => {
setTimeout(() => {
setData([]);
}, 5000);
}, []);
const columns = [
{
title: "id",
colKey: "id",
},
];
// 当前示例包含:输入框、单选、多选、日期 等场景
return (
<Table
rowKey="key"
columns={columns}
data={data}
pagination={
data?.length
? {
defaultPageSize: 10,
defaultCurrent: 1,
total: data?.length,
}
: null
}
/>
);
}

期望结果

No response

实际结果

No response

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

Tasks

Preview Give feedback
No tasks being tracked yet.
Copy link
Contributor

👋 @jacksonjin,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@jacksonjin jacksonjin changed the title [组件名称] 描述问题的标题 [Table] 描述问题的标题 Jun 19, 2024
@jacksonjin jacksonjin changed the title [Table] 描述问题的标题 [Table] pagination 使用三元符并且data为空时,页面会展示之前数据的前十条数据 Jun 19, 2024
@NWYLZW NWYLZW added need more info 需要更多信息理解 issue 的问题 Working as intended The behavior described is the intended behavior; this is not a bug labels Jun 20, 2024
@NWYLZW
Copy link
Collaborator

NWYLZW commented Jun 20, 2024

image sandbox 无法访问(补充 sandbox 后可以重新打开 issue)

看贴出来的代码应该是是按照逻辑预期工作的

@NWYLZW NWYLZW closed this as completed Jun 20, 2024
@jacksonjin
Copy link
Author

图像 sandbox 无法访问(补充 sandbox 后可以重新打开的问题)
看贴士代码应该是按照逻辑预期工作的

现有逻辑是有问题的呀,sandbox 的内容是 贴出来的代码,执行一下下就知道了!

@HaixingOoO
Copy link
Collaborator

图像 sandbox 无法访问(补充 sandbox 后可以重新打开的问题)
看贴士代码应该是按照逻辑预期工作的

现有逻辑是有问题的呀,sandbox 的内容是 贴出来的代码,执行一下下就知道了!

现在是sandbox你给的链接是不是你自己打开可以看,我们打开看不了代码,也就是你设置了私有,没公开仓库,我们访问不了

@jacksonjin
Copy link
Author

import React, { useState, useEffect } from "react"; import { Table } from "tdesign-react";

export default function EditableCellTable() { const arr = Array.from({ length: 100 }, (_, index) => ({ id: index + 1 }));

const [data, setData] = useState(arr);

useEffect(() => { setTimeout(() => { setData([]); }, 5000); }, []); const columns = [ { title: "id", colKey: "id", }, ]; // 当前示例包含:输入框、单选、多选、日期 等场景 return ( <Table rowKey="key" columns={columns} data={data} pagination={ data?.length ? { defaultPageSize: 10, defaultCurrent: 1, total: data?.length, } : null } /> ); }

import React, { useState, useEffect } from "react";
import { Table } from "tdesign-react";

export default function EditableCellTable() {
const arr = Array.from({ length: 100 }, (_, index) => ({ id: index + 1 }));

const [data, setData] = useState(arr);

useEffect(() => {
setTimeout(() => {
setData([]);
}, 5000);
}, []);
const columns = [
{
title: "id",
colKey: "id",
},
];
// 当前示例包含:输入框、单选、多选、日期 等场景
return (

); } 这个是 sandbox 里边的内容 随便在tdesign的一个官网上打开一个 sandbox ,执行上边的代码就能复现 ![image](https://github.com/Tencent/tdesign-react/assets/71485170/1ffd54e9-7f84-4ca3-842b-5f8708fcefbb)

@HaixingOoO HaixingOoO reopened this Jun 21, 2024
@HaixingOoO HaixingOoO added 🐞 bug Something isn't working and removed need more info 需要更多信息理解 issue 的问题 Working as intended The behavior described is the intended behavior; this is not a bug labels Jun 21, 2024
HaixingOoO added a commit to HaixingOoO/tdesign-react that referenced this issue Jun 21, 2024
@NWYLZW NWYLZW closed this as completed in 642d4f1 Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants