phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
315 stars 90 forks source link

Proposal: allow optional scroll restoration on reload #144

Closed vanderhoop closed 6 months ago

vanderhoop commented 7 months ago

Use case: updating UI code for components that exist far down a page.

Problem: At the moment, lightly tweaking a heex component or .heex file (consider the frequent task of adding/removing tailwind classes during UI work) results in a full page refresh on every save, but the scroll position is lost with each refresh. This necessitates manual scroll restoration (and a loss of flow) for the developer when they are working on components below the fold.

Proposal: expose an optional config, :scroll_restoration, which, if true, results in the scroll position being restored on refresh.

vanderhoop commented 7 months ago

Closing, as this appears to be an issue only in liveviews, and not something related to phoenix_live_reload. 👈 Correction: this appears to also be an issue in deadviews

josevalim commented 7 months ago

That’s because changing .ex files cause a full request in order to recompile. Changing CSS only reloads assets instead. There was a discussion about supporting partial reloads for .heex templates but it comes with pitfalls.

vanderhoop commented 7 months ago

@josevalim given the full reload, I think the proposal above makes sense and would provide value. Cool if I reopen?

I'd be happy to take on the work.

vanderhoop commented 7 months ago

I'm actually not confident that my issue would be fixed by this proposal, as liveview itself does some non-trivial scroll position changes...

vanderhoop commented 7 months ago

I'm actually not confident that my issue would be fixed by this proposal, as liveview itself does some non-trivial scroll position changes...

Disregard. The scroll changes in liveview only occur after patches, and won't conflict with the changes in #145

chrismccord commented 6 months ago

https://github.com/phoenixframework/phoenix_live_reload/pull/145#issuecomment-1971890773