turbo: Missing Turbo-Frame header when submitting a form

When clicking links while inside a frame, the Turbo-Frame header will be set.

This helps the backend to know this is a frame request and for instance to not render layout.

When submitting a form, this header is not set, I think it should be.

Example : To respect progressive enhancement, we should be able to return a frame when the request comes from turbo, but perform a redirection when not.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@seanpdoyle using beta 4. Turbo header is not sent with POST request, only GET.

@tleish that’s intentional: see #52 and #127.

Ah. I did not realize this was intentional. I also didn’t realize I could not use turbo-stream with a GET method.

I am still experiencing the issue in beta-4.

GET (links) send the header. POST (form submissions) do not.

In the following example, only the first GET button will include a request header with Turbo-Frame, the other 2 do not include it in the header.

<%= turbo_frame_tag 'user_frame' do %>
  <%= button_to('Edit User', '/users/1', method: "get") %>    <!-- ADDS header['Turbo-Frame'] --> 
  <%= button_to('Save',      '/users/1', method: "post") %>   <!-- NO header['Turbo-Frame'] --> 
  <%= button_to('Delete',    '/users/1', method: "delete") %> <!-- NO header['Turbo-Frame'] --> 
<% end %>

Is this intended or a bug?

using: @hotwired/turbo 7.0.0-beta.3

Sorry if it wasn’t clear, I was advocating to set the Turbo-Frame header only when a form within a frame is being submitted