feat: preserve list state between form navigation #425
+129
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's been feedback from testers that it can be distruptive to loose the list state when navigating between the form and list. This PR implements enhancements to preserve the list state (eg. the query-params used to store list-filters and pagination).
Implementation details
zustan
) and keep that in sync with query-params. So I decided to try outlocation.state
.search
-params string inlocation.state
when navigating from a link that navigates to the form. This is done by passingstate
tonavigate
or as a prop toreact-router
sLink
-component.useQueryParams
the same - and we reapply it by appending the search-params to links that link back - by settingsearch: location.state.search
. The same way is done if we useuseNavigate
oruseLinkClickHandler
.useLocationSearchState
- but it's still up to the Link and navigation components to pass the states correctly.