metropolitan-bronze•3d ago
paginated list return to different page after edit
when I am in a paginated list, i want to return to for exemple page 3 after an edit
11 Replies
Hi @SetiZ. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To ensure that after editing an item in a paginated list you return to the same page (e.g., page 3), you should enable URL synchronization for pagination state. In Refine, this is achieved by using the
Pass
With
By default, after editing, Refine redirects to the list page. With
Enable
syncWithLocation option.
How to do it:
1. Enable URL Sync Globally:Pass
options={{ syncWithLocation: true }} to your <Refine /> component. This will synchronize pagination, filters, and sorting with the URL, so when you navigate back from the edit page, you return to the same page and state.
See documentation
2. How it works:With
syncWithLocation enabled, the useTable hook will:
- Read pagination, filters, and sorting from the URL on load.
- Update the URL when these parameters change.
- When you navigate away (e.g., to an edit page) and then return (e.g., via browser back or navigation), you’ll land on the same page with the same filters and sorting.
This feature addresses the exact scenario you described and is the recommended approach in Refine for preserving list state between navigations GitHub Issue #1410.
3. Redirect Behavior:By default, after editing, Refine redirects to the list page. With
syncWithLocation, the list page will restore the correct page and filters from the URL. If you want to customize redirect behavior further, you can use the redirect option in <Refine /> or in your form hooks, but for most cases, enabling syncWithLocation is sufficient Core Refine options.
Summary:Enable
syncWithLocation to preserve pagination and filters in the URL, ensuring you return to the correct page after editing an item in a paginated list. This is the recommended and built-in solution in Refine.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@267689263246606336> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
metropolitan-bronzeOP•3d ago
@kapa.ai do i need to add the pagination info when i edit and clic save to return to the exact page I was in the list?
Let me check the knowledge base for you again. One moment! :books:
----------------------
No, you do not need to manually add the pagination info when you edit and click save, as long as you have enabled the syncWithLocation feature in Refine. When syncWithLocation is set to true (either globally via the <Refine /> component or in the relevant hook), Refine automatically encodes the pagination, filters, and sorting state into the URL. This means that when you return to the list after editing (for example, by clicking save), you will be brought back to the exact page and state you were on, without needing to handle pagination info yourself.
This behavior is confirmed in the documentation and community discussions, which state that syncWithLocation ensures the list state (including pagination) is preserved in the URL and restored when navigating back from an edit page. You do not need to manually manage or append pagination parameters for this to work—Refine handles it for you when syncWithLocation is enabled Documentation: useTable syncWithLocation GitHub Issue #1410.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@267689263246606336> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
metropolitan-bronzeOP•3d ago
@kapa.ai if i use useParsed to pake sure on the redirect i have it automatically on the right page
Let me check the knowledge base for you again. One moment! :books:
----------------------
Yes, you can use the useParsed hook to access the current pagination, filters, and sorting parameters from the URL. This allows you to programmatically redirect back to the exact page and state you were on after an edit.
The useParsed hook provides you with the current route, resource, action, and all query parameters, including pagination info like current (page number) and pageSize. Here’s an example of how you might use it:
This approach ensures that when you redirect after saving, you include the same pagination and filter parameters, so the user returns to the correct page and state in the list. This is especially useful if you want to have fine-grained control over navigation, beyond what syncWithLocation provides automatically useParsed documentation.
If you are already using syncWithLocation, this is usually handled for you, but useParsed gives you the flexibility to manually control the redirect if needed.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@267689263246606336> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
metropolitan-bronzeOP•3d ago
@kapa.ai i use already syncWithLocation but it goes bakc to the first page
Let me check the knowledge base for you again. One moment! :books:
----------------------
If you are already using
With
syncWithLocation but after editing and saving you are returned to the first page instead of the page you were on, this is not the expected behavior. With syncWithLocation enabled, Refine should preserve pagination, filters, and sorting in the URL, and you should return to the same page after navigation.
However, there have been reports of issues where pagination is not preserved after certain actions or after upgrading Refine versions. For example, users have reported that after a page refresh, the current page resets to 1, or after saving, the list view jumps to the default state, even with syncWithLocation active. These issues have been acknowledged and addressed in various GitHub issues and releases:
- Issue #7042: Reports that after upgrading to v5, the current page resets to 1 on refresh.
- Issue #2123: Mentions that after clicking save in Edit view, the page jumps to the default state in List view, even with syncWithLocation active.
If you are experiencing this, it may be due to a bug in the version you are using. The recommended steps are:
1. Update Refine and related packages to the latest version, as several fixes have been released to address these issues.
2. Double-check that syncWithLocation is enabled both globally (in <Refine options={{ syncWithLocation: true }}>) and in your hooks if needed.
3. If the issue persists after updating, consider checking the open and closed issues on the Refine GitHub repository for similar reports and possible workarounds.
If you are still facing the problem after these steps, it may be a bug that needs to be reported or followed up on GitHub.
Summary:With
syncWithLocation enabled, you should return to the correct page after editing. If you are not, update your packages and check for known issues, as this has been reported and fixed in recent versions GitHub Issue #7042 GitHub Issue #2123.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@267689263246606336> Kapa.ai is still learning and improving, please let me know how I did by reacting below.