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

Update Pagination.tsx #551

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
function handleChange(page: number) {
if (isValid(page) && !disabled) {
const currentPage = calculatePage(undefined, pageSize, total);
let originalPage = page;
let newPage = page;
if (page > currentPage) {
newPage = currentPage;
Expand All @@ -214,7 +215,7 @@ const Pagination: React.FC<PaginationProps> = (props) => {
}

setCurrent(newPage);
onChange?.(newPage, pageSize);
onChange?.(newPage, pageSize, originalPage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该自己可以存一下上次的page就可以了吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有个场景是最大只加载1-10页,也就是分页只显示1...3.4.5....10 , [加载更多],但是实际上有100页;
点击加载更多变为 1...3.4.5....20;
但是从Input输入框键入的时候,会有个最大页数的判断; 所以如果键入30,但是只能调到20;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以就想能够获取到Input键入的原始页数;来自行处理这种情况的逻辑

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

比如你当前页显示的分页为1....5.6.7....10 ;
我键入了30,这时候我就可以判断total/pagesize是否满足跳转30页的条件;
如果满足 ,我分页显示为 1......18.19.20.....30 并跳转到30;
如果不满足,我就可以调到当前最大页;


return newPage;
}
Expand Down
Loading