-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Pagination - fix issue when step size changes and current page isn't visible #7237
base: master
Are you sure you want to change the base?
Conversation
more of a question.. should the user be put back to page one? after re-selecting Screen.Recording.2024-05-21.at.2.09.00.PM.mov |
I put them on the last page because then they would be closer to the data that they were previously viewing before changing the step |
gotcha just wanted to make sure that was the correct pattern! |
To just speak out loud, is it correct to say our logic is "as I'm trying to figure out what I'd expect in a scenario like this where I was on page 14, then increased the step, and then was on the last page of data. Screen.Recording.2024-05-22.at.3.17.04.PM.mov@halocline any thoughts on behavior? |
I agree that we should pause and think through this a bit further. The page 14 to last page scenario isn't right - because last page is much further away. We are either "smart" and do something like ensure the index of the first item in the current page is in the resulting subset in the next page. Or, always go back to page 1. We also need to consider the controlled scenario as well. |
I'm confused by the statement 'last page is much further away', if we have a scenario where we are on page 14 and the step changes in such a way that page 14 no longer exists and we are moved to the last page then the data on the last page will include data from page 14 |
I think point is that isn't necessarily true. You probably could do the math to figure out what page in the new step size contains the top item from the previous current page. But we do need to think a little more about the various cases and if we're screwing up the controlled situations (ie. not letting the caller control where it ends up when step changes.) |
Ah okay I was thinking of page 14 as the last page, but if page 14 is a middle page I see what you are saying. |
Slow brain haha sorry, should we just default to going back to the first page? Unless Pagination is in a controlled state then we wouldn't do anything |
Writing out logic for going back to Page 1
If a different behavior is desired then it can be achieved through a controlled version of Pagination |
Writing out logic for keeping previously visible data visible
If a different behavior is desired then it can be achieved through a controlled version of Pagination |
What does this PR do?
Fixes an issue in Pagination when you are on a page and then change the step size in such a way that the current page you are on no longer exists. The current behavior is that no page will be selected, this PR changes the behavior so that the user lands on the last page (this is so that they will be closest to the data they were previously viewing before changing the step size).
Where should the reviewer start?
What testing has been done on this PR?
Added jest test and tested with existing storybook stories
How should this be manually tested?
Do Jest tests follow these best practices?
screen
is used for querying.asFragment()
is used for snapshot testing.Any background context you want to provide?
What are the relevant issues?
Closes #7215
Screenshots (if appropriate)
Do the grommet docs need to be updated?
no
Should this PR be mentioned in the release notes?
yes
Is this change backwards compatible or is it a breaking change?
backwards compatible