hotwired / turbo

The speed of a single-page web application without having to write any JavaScript
https://turbo.hotwired.dev
MIT License
6.54k stars 415 forks source link

Preserve scroll position when morphing turbo frames #1272

Open danielfriis opened 4 weeks ago

danielfriis commented 4 weeks ago

I have a Turbo Frame that looks something like this:

<%= turbo_frame_tag :messages, src: messages_path, target: "_top", refresh: "morph" %>

I've added refresh: 'morph' to allow it to morph when things change in the frame.

However, the scroll position is reset every time this happens.

Let's say I delete a message, then the scroll position is reset, and I'm back at the top of the frame.

It seems that we are missing an attribute to preserve the scroll position.