-
Notifications
You must be signed in to change notification settings - Fork 429
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
Missing Turbo-Frame header when submitting a form #86
Comments
Adding the For invalid forms, we recommend responding with the 422 HTTP status and the form contents will be replaced. See #39. You can also respond with turbo streams. |
Sorry if it wasn't clear, I was advocating to set the |
Ah! Yeah, that should be set, and if not, it's a bug. |
Hi! If this is a bug, then I can also confirm it :). Inside the a frame, when I click a link, I can see the Cheers! |
In the following example, only the first GET button will include a request header with <%= 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: |
I can confirm this issue (using Django):
|
If you prefer an alternative approach than PR #110 I'm happy to work on it. |
Run into the same issue today (using hotwire with Golang backend). Looks like the suggested fix is still hanging :-\ |
As part of #142, we changed how the headers are constructed from a merge operation to a direct mutation. Combined with #127, all form submissions (GET or POST, inside a frame or referencing one from the outside) should result in a requests with the Turbo-Frame header. That behavior was shipped as part of https://github.com/hotwired/turbo/releases/tag/v7.0.0-beta.4. @Intrepidd @danjac @oleksandr are you still experiencing this issue? |
I am still experiencing the issue in beta-4. GET (links) send the header. |
Closes hotwired#86 Recursively walk the tree of dependent FetchRequestDelegates so that they all have an opportunity to modify the fetch request headers. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
Closes hotwired#86 Recursively walk the tree of dependent FetchRequestDelegates so that they all have an opportunity to modify the fetch request headers. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
Closes hotwired#86 Closes hotwired#110 Recursively walk the tree of dependent FetchRequestDelegates so that they all have an opportunity to modify the fetch request headers. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
Closes hotwired#86 Closes hotwired#110 Recursively walk the tree of dependent FetchRequestDelegates so that they all have an opportunity to modify the fetch request headers. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
@seanpdoyle — created this JSFiddle to show the headers being sent. Click any of the buttons and see the headers sent through fetch below the buttons. Turbo only adds turbo-frame to header on a GET. |
Closes hotwired#86 Closes hotwired#110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
Closes hotwired#86 Closes hotwired#110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit changes the `FetchRequest.headers` property to be `readonly` and created at constructor-time so that its values can be mutated prior to the request's submission. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
One other item to note, should the GET request also include |
@tleish that's intentional: see #52, #127, and hotwired/turbo-site#40 (comment). |
@seanpdoyle using beta 4. Turbo header is not sent with POST request, only GET. |
I confirm as well, header is still not sent for my POST use-case |
Closes #86 Closes #110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit changes the `FetchRequest.headers` property to be `readonly` and created at constructor-time so that its values can be mutated prior to the request's submission. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
Closes #86 Closes #110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit introduces a readonly `FetchRequestHeaders` property created at constructor-time so that its values can be mutated prior to the request's submission. Co-authored-by: tleish <tleish@users.noreply.github.com>
Closes hotwired#86 Closes hotwired#110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit introduces a readonly `FetchRequestHeaders` property created at constructor-time so that its values can be mutated prior to the request's submission. Co-authored-by: tleish <tleish@users.noreply.github.com>
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.
The text was updated successfully, but these errors were encountered: