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

Pagination component does not keep state when navigating away from it #3868

Closed
erral opened this issue Nov 10, 2022 · 7 comments · Fixed by #4159 or #4698
Closed

Pagination component does not keep state when navigating away from it #3868

erral opened this issue Nov 10, 2022 · 7 comments · Fixed by #4159 or #4698

Comments

@erral
Copy link
Sponsor Member

erral commented Nov 10, 2022

Describe the bug

When the user navigates away from a listing that has pagination, the listing block doesn't keep the state on which was rendered, and if the user goes back to the listing block, the pagination state is recalculated and rendered again from the 1st page.

To Reproduce
Steps to reproduce the behavior:

  1. Add a Listing or a Search block and configure it in such a way that it has more than 1 page in the results.
  2. Browse the page with the block you have just created and go to the 2nd page
  3. Click in a result item and go to its page
  4. Use the back button in the browser
  5. The listing block results are rendered again but they show the 1st page

Expected behavior
After going back I expect to be in the same page that I was before I left the page

Additional context
There is no querystring like ?page=1, or b_start=20 or something like that that could help on getting the actual page the user was on.

@tiberiuichim
Copy link
Contributor

there needs to be something like what SearchBlock is using: https://github.com/plone/volto/blob/master/src/components/manage/Blocks/Search/hocs/withSearch.jsx#L200

This is a complicated problem space: it's easy to overdo it and end up with performance issues, or long/ugly URLs

@davisagli
Copy link
Sponsor Member

@tiberiuichim What kind of performance issues are you thinking about? You mean from clients trying to change the batch size to load too many items at once, or search engines following the links to index all of the pages without rate limiting?

@erral
Copy link
Sponsor Member Author

erral commented Nov 10, 2022 via email

@tiberiuichim
Copy link
Contributor

@davisagli I think I used the wrong term when I wrote "performance". I was mainly thinking of how to stash all the listing block states in URLs, considering that there can be multiple listing blocks on a page.

@davisagli
Copy link
Sponsor Member

davisagli commented Nov 10, 2022

@tiberiuichim I see. Yeah, that's tricky. To keep things simpler, could we decide to only support this for the first listing block on a page?

Or maybe we could stash the pagination state in sessionStorage keyed by block uid and not try to sync it with the URL.

@tiberiuichim
Copy link
Contributor

We could use the persistentReducers to keep the state synced to localStorage.

I wish, though, that the current implementation of our persistentReducers would use session storage instead of local storage.

@erral
Copy link
Sponsor Member Author

erral commented Nov 11, 2022

In Plone batches the developer can pass an additional parameter setting the request variable name this way you can have several batches in one page one being b_start=10 and the other c_start=8, perhaps something like this could be doable here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants