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] newData of onPageChange is not correct #1840

Merged
merged 2 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/table/_example/pagination.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const statusNameListMap = {
};

const data = [];
const total = 60;
const total = 59;
for (let i = 0; i < total; i++) {
data.push({
index: i,
Expand All @@ -26,6 +26,7 @@ for (let i = 0; i < total; i++) {
}

const columns = [
{ colKey: 'serial-number', width: 80, title: '序号' },
{ colKey: 'applicant', title: '申请人', width: '100' },
{
colKey: 'status',
Expand All @@ -42,14 +43,16 @@ const columns = [
},
},
{ colKey: 'channel', title: '签署方式', width: '120' },
{ colKey: 'detail.email', title: '邮箱地址', ellipsis: true },
// { colKey: 'detail.email', title: '邮箱地址', ellipsis: true },
{ colKey: 'createTime', title: '申请时间' },
{ colKey: 'row-select', type: 'multiple', width: 46 },
];

export default function TableBasic() {
const [reserveSelectedRowOnPaginate, setReserveSelectedRowOnPaginate] = useState(true);
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
// const [current, setCurrent] = useState(2);
// const [pageSize, setPageSize] = useState(5);

return (
<Space direction="vertical" style={{ width: '100%' }}>
Expand Down
7 changes: 1 addition & 6 deletions src/table/hooks/usePagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ export default function usePagination(props: TdBaseTableProps) {
onChange={(pageInfo: PageInfo) => {
props.pagination?.onChange?.(pageInfo);
setInnerPagination(pageInfo);
let newData = dataSource;
// 如果是非受控情况的分页变化,还需更新分页数据(data)
if (pagination && !pagination.current && pagination.defaultCurrent) {
newData = updateDataSourceAndPaginate(pageInfo.current, pageInfo.pageSize);
}
// TODO: dataSource
const newData = updateDataSourceAndPaginate(pageInfo.current, pageInfo.pageSize);
props.onPageChange?.(pageInfo, newData);
}}
/>
Expand Down
Loading