Skip to content

Location not updated when clicking on same-page fragment links #762

@kevinmcconnell

Description

@kevinmcconnell

When clicking on a link to a fragment on the current page, the location in the address bar does not update to reflect the fragment. However, clicking the same link a second time in a row does update it.

This behaviour seems to have been introduced in #601.

A simple reproduction is as follows:

<!DOCTYPE html>
<html>
  <head>
    <script src="https://cdn.jsdelivr.net/npm/@hotwired/turbo@7.2.0/dist/turbo.es2017-umd.min.js"></script>
  </head>

  <body>
    <h1 id="id1">one</h1>
    <h1 id="id2">two</h1>

    <a href="#id1">one</a>
    <a href="#id2">two</a>
  </body>
</html>

On this page, clicking the anchor tags does not update the location in the browser address bar. Clicking the same link twice in a row will update it.

When using a version prior to #601, like Turbo 7.1.0, the location updates correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions