turbo: data-turbo-action="advance" doesn't update browser URL

The documentation says that the browser URL will be updated if data-turbo-action="advance" is set on a link or a turbo frame. Unfortunately, only the src attribute of the turbo frame is updated. When using Turbo.visit(), the src attribute and the browser url are updated.

I’m using version 7.0.1.

Is this related to #468?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@dhh @seanpdoyle this issue is regressed since 7.3.0, can we get this issue back open?

Are we sure this is working? I’m creating a fresh Rails 7 application, have included stimulus-rails and turbo-rails in Gemfile and package.json contains "@hotwired/turbo-rails": "latest" under "dependencies". yarn.lock indicates I’m using 7.1.3 of @hotwired/turbo.

My view contains <turbo-frame data-turbo-action="advance" id="header" target="main"><a href="..."></a></turbo-frame> and further a <turbo-frame id="main"></turbo-frame>. I would expect the page’s URL to change when clicking the link.

Same for me, I’m using "@hotwired/turbo-rails": "^7.3.0", and Turbo.visit('/...', { frame: 'results', action: 'advance' }) doesn’t update URL of the page

I’d expect the following to update my URL but it doesn’t 😦 Turbo.visit(url, { frame: 'a', action: 'advance' })

As a workaround, I added a controller to my rendered html that when connected passes values for the page name and path I want to set

 <div data-controller="url" data-url-page-value="Page Name" data-url-path-value="/appended_path"></div>
export default class extends Controller {
  static values = {
    page: String,
    path: String,
  }

  connect() {
    window.history.replaceState(window.history.state, this.pageValue, this.pathValue)
  }
}

I suspect this issue was introduced here, as before this change options were taken into account, but not any longer after that change. And Turbo.visit lands here. cc @seanpdoyle

when i manually update the src attribute of a frame with “data-turbo-action” set to “advance” the url doesn’t change. I’m missing something ? When i click a link inside a frame everything is working as expected.

@seanpdoyle - this is of course a bit premature, but it feels like this could be a limitation in the initial implementation in #398. 🤔 Would you like an isolated test case or could you give it a look regardless?

To make things reasonably clear, we’re talking about scenarios like this:

<body>
  <turbo-frame id="nav" target="content" data-turbo-action="advance">
    <!-- Links inside this frame are broken; the data-turbo-action properly is not properly honored -->
    <a href="/link-one">Link one</a>
    <a href="/link-two">Link two</a>
  </turbo-frame>

  <turbo-frame id="content" data-turbo-action="advance">
    <!-- Links inside this frame works correctly re. URL/history, with the limitations described in
         earlier comment -->
    <a href="/link-three">Link three</a>
  </turbo-frame>
</body>

I’ve added test coverage to https://github.com/hotwired/turbo/pull/1135 to attempt to resolve this issue. Unfortunately, I was able to pass the test without any implementation changes. Could you review that diff (mainly https://github.com/hotwired/turbo/pull/1135/files#diff-1e84a1526802b27615a24efc0f9b75c27b2a9197d855a8ccc5475db14609ed6f and https://github.com/hotwired/turbo/pull/1135/files#diff-4706705ec52e666c36d3cd9410d3aad96354c69f61a18f880b40291836485f36R655-R663 to help me reproduce the underlying issue more closely?

May or not be related, but I’m experiencing a similar issue even without manually setting action: 'advance':

    Turbo.visit(url, {
      frame: 'my-frame',
    });

Updates the src attribute on the frame but does not update the URL. "@hotwired/turbo": "^7.3.0"

Solved changing package.json to "@hotwired/turbo-rails": "^7.1.0" and run yarn upgrade turbo