Visiting the current URL doesn't reload the turbo frame
See original GitHub issueI have a link that points to the current URL (acting as a reload button), and it targets a turbo frame.
Clicking on the link the first time works; the frame is reloaded, and the src
value of the frame is updated. Clicking on the link the second time doesn’t work, there are no HTTP requests being made, and the frame is not reloaded.
I’m assuming it’s because Turbo doesn’t detect that src
has changed, since it’s the same link. However, this is not how regular links behave, you can always visit the current page, so I think it would make sense for Turbo to have the same behaviour.
Possibly related to https://github.com/hotwired/turbo/issues/249#issuecomment-830124904 and https://github.com/hotwired/turbo/issues/202.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:12 (7 by maintainers)
Top Results From Across the Web
how can I reload a single turbo frame and update the url?
open index.html in a browser · click the 'full page' link, observe that bonus number changes, query string is now in URL and...
Read more >Turbo Frames with Browser Destination/URL Replacement
I want to have the search query “persist” between page navigation and so I used a Turbo Frame to do exactly that with...
Read more >Turbo Frames Vs. Turbo Streams - Learn Ruby on Rails
Turbo Frames are great for taking an old-style full-HTML page and turning it into a modern, responsive-looking page in minutes.
Read more >Using Rails Turbo Frames
Turbo Frames is a set of tools that can replace complex, ... from links in the background without needing to perform a full...
Read more >Making a Single Page Search with Turbo
This happens because each turbo-frame creates its own navigational context. By default all links and form submissions from within a given turbo- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t understand why reloading the current URL is not allowed. This behaviour is counterintuitive to me. Adding a timestamp works as a temporary workaround. Reloading a frame can be useful to easily reset a frame’s initial state.
Thanks for the reply. We initially used the approach of clearing the
src
first, but then we switched to adding a timestamp to the URL.However, I don’t understand in which scenarios is this kind of caching useful. Personally, I would expect caching to only happen based on caching-related HTTP response headers.
I actually feel like this unexpected behaviour is coming from Turbo Frames possibly being designed to only watch for
src
changes on the frame, considering thatnavigateFrame
only changes the frame’ssrc
. In this case it’s obvious there is a limitation of not detecting reloads.