Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-turbo-action: 'advance' ignored on link within turbo-frame in v7.2.0 #389

Closed
diachini opened this issue Sep 30, 2022 · 3 comments
Closed

Comments

@diachini
Copy link

TLDR

Bumping from v7.1.0 to v7.2.0 seems to be causing data-turbo-action: 'advance' to not update the URL when a link is inside a different turbo-frame.

Explanation

In v7.1.0, it was possible to have:

<%= turbo_frame_tag "modal" %>

<%= turbo_frame_tag "other_frame" do %>
  <%= link_to "New post", new_post_path, data: { turbo_frame: "modal", turbo_action: 'advance' } %>
<% end %>

which would have the New post link render its response in the modal frame, and data-turbo-action: 'advance' was properly updating the URL to the /posts/new path:

image

With the bump to v7.2.0, it's still able to render the response in the modal frame, but the advance is no longer updating the URL.

Reproduction

  • Clone https://github.com/diachini/turbo_rails_advance_in_frame
  • bin/rails db:migrate
  • bin/rails s
  • Visit http://localhost:3000/posts/
  • See that:
    • New post (from other_frame - broken) does not update the URL to /posts/new
    • New post (not in a frame - advances) does update the URL as expected
    • New post (from the same frame - advances) does update the URL as expected
  • Checkout the v7.1.0_advance_works_fine branch (which pins @hotwired/turbo and @hotwired/turbo-rails to v7.1.0)
  • See that the link from other_frame does update the URL to `/posts/new'

Version information

Rails 7.0.4
Turbo-rails gem 1.3.0
@hotwired/turbo-rails 7.2.0
@hotwired/turbo 7.2.0

@pasl
Copy link

pasl commented Sep 30, 2022

I found that you have to specify a turbo-method in order to make it work with 7.2.0.

= link_to "User list", users_path data: { turbo_action: "advance", turbo_method: 'get' }

I didn't investigate but maybe this is related to this fix : #389

It doesn't make sense to specify a method on a link_to or at least it should be GET by default.

@diachini
Copy link
Author

diachini commented Oct 3, 2022

Thanks for the workaround @pasl! I agree that GET should be the assumed default. It certainly seems like the PR you originally linked to (hotwired/turbo#636) touches related code even if it's not the smoking gun for this default assumption changing in v7.2.0.

@diachini
Copy link
Author

It appears this issue is now resolved as part of v7.2.2. Perhaps thanks to hotwired/turbo#749 resolving a similar issue with navigation inside another <turbo-frame>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants