Discovering Turbo 8 refreshes in Ruby on Rails
I'm working on a personal project in which I'm trying to squeeze every ounce of features from Turbo and in doing so I found something that I thought was a bug.
When going from a simple page that uses the scroll: preserve
attribute (docs) and the default method: :replace
(docs) to one that uses lazy-loading turbo frames, sometimes the scroll preservation seems to fail. After digging a lot, it turns out the preservation was actually working but my assumptions of how it worked in tandem with lazy-loaded frames was wrong.
I made a video explaining the whole journey using a very simple test case in Rails:
TL;DW (Too long, didn't watch) -- spoiler alert!
Scroll is preserved with lazy-loading frames. The problem comes from the height of elements while the content is lazy loaded. It's a "problem" that you can actually fix very easily using Turbo 8 page refreshes and morphing!
Let me know what you think of this format! Is the first time I publish a screencast so any feedback is more than welcome (other than "buy a pop filter" 😅 I KNOW NOW lol)
Subscribe to my newsletter
Read articles from Julián Pinzón Eslava directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by