phoenix_live_view icon indicating copy to clipboard operation
phoenix_live_view copied to clipboard

live_redirect does not remember scroll position if a live_patch is done before it

Open dvic opened this issue 2 years ago • 4 comments

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

  1. load liveview A and scroll down
  2. cilck on a live_redirect to liveview B
  3. browser back returns to original scroll position of liveview A

SITUATION 2 (same as SITUATION 1 but with a live_patch in between)

  1. load liveview A and scroll down
  2. do live_patch, scroll more down
  3. cilck on a live_redirect to liveview B
  4. 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.

dvic avatar Jun 24 '22 14:06 dvic

If it helps, I can make a repo that reproduces this.

dvic avatar Jun 24 '22 14:06 dvic

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

dvic avatar Jun 29 '22 10:06 dvic

Just checked if #2097 fixed this issue: it does not 🙁

dvic avatar Jul 08 '22 17:07 dvic

Update: #2173 fixes this issue :)

dvic avatar Sep 06 '22 06:09 dvic