I have an index view where you can open the detail view of a particular item. The index view has paging and search criteria. When I navigate back from the child view, the current page and search criteria is lost. I can think of two solutions.
Save the current page/search criteria in the browser URL. This has the added benefit of being bookmarked for a given search criteria. The question then is, how does the detail page know to go back to this URL instead of the index page using the Router helpers. Does the URL get saved in session state?
Save the page/search criteria in session state. The index page would dig out these params in the mount callback.
Finally, where does one save such temp info?
You could stay on the same view and change the contents of it, or pass a
return_to link to the detail view which it can use to get back, or pass the params you want to keep on hand to the link to the other page. You can do that with
Routes.live_path(Endpoint, ..., some: "thing", other: "thing").
push_patch to keep the query params updated, so that you can copy paste the URL, go back and forward. This way you handle most changes in
Yes, that is the solution that I landed on. I pass a return_url param on the child link as a query param. The child can then just use the return_url to get back to the correct page/search.
This feels clunky. I would rather:
- combine the 2 liveviews into one. or
- just do
history.back() from the client side