Trubo makes <a href="#asdf"> scroll to the top

If you have an anchor tag like <a href="#foo"> that goes to an <h2 id="foo"> turbo will scroll to the top of the page. Is there a good way to disable this behavior? It also fails on page loads.

This should mostly work as expected unless <h2 id="foo"> does not exist when the page loads (e.g. it’s lazily loaded). There is currently a bug with the way that Turbo handles anchors to same-page elements. I have a PR to fix this here: Prevent reloading pages when tapping same-page anchors by domchristie · Pull Request #125 · hotwired/turbo · GitHub

Thanks! I mannaged to fix my problem with using data-turbo="false" which I found because of the issue you linked. Example for others experiencing something similar:

 <a data-turbo="false"
    href="#<%= category %>"><%= category %> </a>

... further down the page

  <h3 id="<%= category %>"><%= category %> </h3>