I have been working on trying to implement an “Application Shell” with navigation on the left and a search bar at the top. I want to have the search query “persist” between page navigation and so I used a Turbo Frame to do exactly that with a data-turbo-frame on the urls outside of the shell for the search results. This works exceptionally well, however it does not change the browser destination/URL.
Are you effectively making all the routes for the navigation just respond as a turbo_stream using the replace action? I never thought of doing that and its actually quite a nice solution, just annoying having to change a lot more routes to use this. Might give that a go to get it properly working!
Another option I thought of is by using the event turbo:before-stream-render and doing some javascript history and URL changes but that may get messy.
Turbo visits reset the window scroll though. I had a very specific use case where I have a search form (GET) on my page that is triggered via checkbox clicks through stimulus, I want each new search to be registered in the browser history for better navigation.
Turbo visits work but reset my scroll which is not convenient, restoring scroll after a visit is a bit tedious and not necessarily reliable, so I ended up implementing a stimulus controller that would update the navigation with the frame navigation : https://gist.github.com/Intrepidd/ac68cb7dfd17d422374807efb6bf2f42
You use the GET as a strategy to detect the turbo-frame event right ( the get method updates the src attribute ) ? … I wish there was a turbo-frame:load event or something like that, it would be nice
You use the GET as a strategy to detect the turbo-frame event right ( the get method updates the src attribute ) ? … I wish there was a turbo-frame:load event or something like that, it would be nice
Hiya – I can see the solution here states to use data-turbo-permanent, but what are you actually attaching data-turbo-permanent to to persist the url…?