-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix pagination issues #273
Conversation
: page; | ||
// If the page number is not a number or not in range, then set it to the | ||
// beginning or ending page depending on which is closer. | ||
if (Number.isNaN(page) || page < BEGINNING_PAGE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if page > RESULTS_PER_PAGE - 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious how RESULTS_PER_PAGE
is related 🤔 The constant RESULTS_PER_PAGE
refers to how many search results are on a page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I referred to the wrong variable. I mean to ask page < BEGINNING_PAGE
is checked on the left side of the range for page number, but how are we checking it on the right side of the range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should be the condition below page > totalPages
for checking the right side of the range 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for getting in these fixes so quickly! 🎉
Description
Fixes issues found during QA:
Demos
https://pagination-frontend.dev.imaging.cziscience.com/
Pagination scrolls to top when changing pages
Before the page would stay at the bottom when navigating.
scroll-on-page-change.mp4
Remove hover state from disabled buttons
Before
After
Open closest extreme for out-of-range pages
Before, the page would always start at page 1 if the page was out of range. Now, the page will be set to the closest extreme:
totalPages
, the page is set to the last page.