Live reloading of HTML/CSS changes forces scroll to top of page

I’ve noticed that when live reloads are triggered the page scroll returns to the very top of the page instead of maintaining scroll position. This is pretty frustrating when designing/building something farther down on the page, since you then have to scroll back to where you were to see the changes.

I’m assuming this is because of how LiveView is re-rendering everything in the DOM, but has anyone found a way around this?

GIF (20MB):

1 Like

I’ve also noticed just reloading pages always scrolls the page back to the top as well, even if you’re just refreshing (and maybe that’s all the live-reload is doing…). Typically browsers will maintain scroll position on pages if you are scrolled down and you refresh the page, but this doesn’t seem to be happening with LiveView-rendered pages.

And I’ve confirmed that this behavior only exists for LiveView rendered pages. Traditional Phoenix views do not exhibit the issue. Reloading the page when scrolled down a bit maintains that same scroll position after reloading, and the live-reload functionality also maintains scroll position when triggering that reload as well.

Oh this might be relevant: