phoenix_live_view
phoenix_live_view copied to clipboard
live_redirect does not remember scroll position if a live_patch is done before it
Environment
- Elixir version (elixir -v): 1.13.4
- Phoenix version (mix deps): 1.6.10
- Phoenix LiveView version (mix deps): 0.17.10
- Browsers you attempted to reproduce this bug on (the more the merrier): chrome, firefox, safari
- Does the problem persist after removing "assets/node_modules" and trying again? Yes: yes
Actual behavior
setup: liveview A and liveview B
SITUATION 1
- load liveview A and scroll down
- cilck on a live_redirect to liveview B
- browser back returns to original scroll position of liveview A
SITUATION 2 (same as SITUATION 1 but with a live_patch in between)
- load liveview A and scroll down
- do live_patch, scroll more down
- cilck on a live_redirect to liveview B
- browser back does not return to original scroll position of liveview A
Expected behavior
I did not expect that a live_patch before a live_redirect would change the way the back button works w.r.t. the scroll position.
Is this intended behavior or a possible bug?
Actual usecase:
List view of items with a "load more button" (which is the live_patch), I'd like to be able to click on one item (liveview B) and go back to the original position in the list.
If it helps, I can make a repo that reproduces this.
Here is the repo that reproduces this: https://github.com/qdentity/lv_reproduction_repo/tree/scroll-bug
and here is a video that shows that the scroll position is lost after "load more" is clicked (which is a live_patch
):
https://user-images.githubusercontent.com/1214337/176419730-d69f880c-a1b8-4f73-a904-28ac309b0f0b.mov
Just checked if #2097 fixed this issue: it does not 🙁
Update: #2173 fixes this issue :)