Hi
I followed the Push history state from frame navigations PR (#398) and the related issues with interest.
What I’m hoping to be able to achieve is that as the user navigates inside a Turbo Frame, the browser location updates so that if the page is bookmarked or shared then the app will be able to restore the page state to how it was when bookmarked.
I haven’t been able to get this to work and was wondering if I’m doing something wrong or if I’m misunderstanding the intent behind this PR?
My current understanding is that a Turbo Frame with data-turbo-action="advance"
added should behave the same as it would without that attribute, with the exception that clicking a link inside the Turbo Frame updates the browser location in addition to updating the frame source. Do I have that right or have I misunderstood?
What actually happens for me is that when clicking a link inside a Turbo Frame with data-turbo-action
there is a brief moment where the contents of the frame is updated (and the rest of the page is unchanged), but then the whole page is replaced as if the link wasn’t in a Turbo Frame.
To illustrate this I scaffolded a minimal todo example in a newly created Rails 7.0.3.1 app (a task model with a title for each task). On the “task show” page I moved the title and the Edit link into a turbo frame so that now clicking to Edit the title replaces the contents of the frame with the edit form, and clicking Save shows the updated title, with all other contents on the page unchanged. i.e. the user experience is similar to editing the issue title on GitHub Issues.
Here’s the commit made to add the turbo frame without data-turbo-action
- this works as described above.
And here’s the commit where I added data-turbo-action
- now clicking on the Edit link results in the whole page being replaced rather than just the frame contents.
Can anyone see what I’m doing wrong? Or at least confirm for me that the intended behaviour for this is as I thought it was, in which case I can keep digging to see if I can figure this out.
Thanks!
Michael