Previous discussion: https://elixirforum.com/t/how-to-restore-scroll-position-in-live-view-app/31548
Going back on link restores the position, but going back on live_redirect doesn鈥檛.
Repro: https://github.com/syfgkjasdkn/scroll-position-live-view
Recording: https://www.dropbox.com/s/hkl11k3l1b8favc/scroll-demo.mp4?dl=0
Scroll position is restored for live_redirect the same way as it is restored for link.
Its appears part of the problem is that on redirect we scroll to the top https://github.com/phoenixframework/phoenix_live_view/blob/6185fad4080dd87abc327dd7b060960c99ecd490/assets/js/phoenix_live_view.js#L988 one possible fix is we could store the scroll position in the pushState meta and if it exists in popstate scroll to it?
This was closed with the 0.14.5 release. Thanks!
Most helpful comment
Its appears part of the problem is that on redirect we scroll to the top https://github.com/phoenixframework/phoenix_live_view/blob/6185fad4080dd87abc327dd7b060960c99ecd490/assets/js/phoenix_live_view.js#L988 one possible fix is we could store the scroll position in the pushState meta and if it exists in popstate scroll to it?