Within my Single Page Application (built with Javascript and AngularJs), I have an items list that is paginated, displaying 10 items per page.
To ensure that the user's current pagination remains intact even when navigating to other pages, I store the current page number in the browser's localStorage. Here is an example scenario:
- The user visits
myItemsList.html
. - They navigate to page 2 using the URL:
myItemsList.html?page=2
. - Next, they visit another page:
myOtherPage.html
. - If they return to the original link for
myItemsList.html
, it will automatically display pagemyItemsList.html?page=2
from localStorage, allowing them to continue where they left off.
However, there may be confusion for the user if they expect to see page 1 as a fresh start of their navigation. To address this potential issue, I am considering adding a label like "Page 2" at the top of the list to indicate that it is part of their previous navigation history. Is this approach user-friendly from a UX perspective?
Alternatively, should I avoid persisting the current pagination altogether?
Here is what could happen if I do not save the current viewed page:
- The user visits
myItemsList.html
. - They navigate to page 2 using the URL:
myItemsList.html?page=2
- Upon opening an item on this page ("show" page), they are taken to:
myItemsList.html?id=123
- Clicking the browser's back button refreshes
myItemsList.html
(since it is a Single Page Application), causing the loss of the current pagination state (page 2). The user would then need to start over to discover more items.
This situation presents a dilemma... What would be the best strategy to handle a use case like this?