LiveView live_patch and scroll to top

I’m curious to know, what is the idiomatic way of scrolling to the top after clicking a live_patch link?

The best I could find is this: Window Y scroll position after following live_link is maintained · Issue #481 · phoenixframework/phoenix_live_view · GitHub

Not sure if this is idiomatic at all (and if not maybe someone will offer a superior solution), but I have used a JS hook like this:

Hooks.ScrollToTop = {
  mounted() {
    this.el.addEventListener("click", e => {
      window.scrollTo(0, 0);

and then include it in your live_patch as such:

<%= live_patch "click me",
      to: Routes.live_path(...),
      class: ...,
      phx_hook: "ScrollToTop" %>

It doesn’t look “perfect” - sometimes you see the page scroll to top a split-second before the patch destination loads. But it’s been “good enough” for my purposes so far.

The last comment on that issue and the linked patch implies to me it should be happening automatically if window.location.href is changing. Is that not the case? Scroll to top on live_link while respecting targets. Closes #517 #481 · phoenixframework/phoenix_live_view@ad96e91 · GitHub

E: Actually the latest code has a few more stipulations:

Note that the scroll only happens for type "redirect" not "patch"