mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-23 17:49:49 +08:00
feat(Table): reset to the first page if there is less data to show
This commit is contained in:
parent
0fb888fff9
commit
9ee265882d
@ -281,6 +281,20 @@ export const Table = implementRuntimeComponent({
|
||||
});
|
||||
}, [currentPageData, mergeState, rowKey]);
|
||||
|
||||
// If there is less data to display than the current page, reset to the first page
|
||||
useEffect(() => {
|
||||
if (useCustomPagination) return;
|
||||
if (currentPageData.length <= Number(pageSize) * (currentPage - 1)) {
|
||||
setCurrentPage(1);
|
||||
}
|
||||
}, [
|
||||
currentPage,
|
||||
currentPageData.length,
|
||||
pageSize,
|
||||
setCurrentPage,
|
||||
useCustomPagination,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
setColumns(
|
||||
cProps.columns!.map((column, i) => {
|
||||
|
Loading…
Reference in New Issue
Block a user