Scroll position and multiple `push_patch/2` calls

The docs for push_patch/2 state that:

[…] new state is pushed to the client, without reloading the whole page while also maintaining the current scroll position. […]

And that’s what I get when I navigate in my imaginary app in this basic workflow:

  • go to /forms (a LiveView route)
  • scroll down to bottom of page
  • click on Test form link that uses <.link patch={~p"/forms/#{form.id}"}> component
  • hit back in the browser, the scroll position is preserved

However, when I use another push_patch/2 to “navigate back” - then the scroll position is reset:

  • click on Test form link that uses <.link patch={~p"/forms/#{form.id}"}> component
  • click cancel link that uses <.link patch={~p"/forms"}>
  • scroll position is lost

How do I preserve the scroll position when navigating with (multiple) push_patch/2 ??

EDIT:
I shall add that my app uses LiveComponent behaviour to render the Test form. It’s almost unmodified output from the phx.gen.live generator.

EDIT 2:
I have rewritten the live component to be functional one, yet the scroll position is still being lost on second push_patch/2. I thought the scroll issue was related to the live_component’s internal state.