-
Notifications
You must be signed in to change notification settings - Fork 440
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
Not updating turbo frames on POST when rendering from controllers #1440
Comments
I just found that the problem is because of the response content type that comes with |
@MatheusPoliCamilo thanks for the follow-up. Should we close this issue? Would an update to the docs be helpful? |
@joelhawksley I've updated the docs, could you take a look in #1442? |
@MatheusPoliCamilo are you using haml for your views? I was facing the same issue you reported, and came across this: hotwired/turbo-rails#287 (comment). It seems that rendering haml files doesn't trigger the appropriate content_type header. Specifying the content_header in the controller is a workaround. It seems to me like a change to haml code is indicated. Or you can change your filenames to filename.html.haml iso filename.haml |
Description
When rendering a
ViewComponent
from the controllers, it isn't updating the turbo frames tags specifically on POST. Using Rails partials it works fine. Using a Rails partial with aViewComponent
inside works too.Steps to reproduce
I made an example in this repository: https://github.com/MatheusPoliCamilo/view_component_1440
Basically a request to this
ExampleController#create
will updates a turbo frame (if the partial renders a turbo frame tag with the expected ID):But the same isn't occurring with the
ViewComponent
, this code doesn't update a turbo frame (considering that it will render a turbo frame tag with the expected ID):Expected behavior
Expected to the rendered
ViewComponent
by Controller updates the turbo frame when finishes the POST request, like when using Rails partials.Actual behavior
The rendered
ViewComponent
by Controller isn't updating the turbo frame tag.Workaround
Specify the
content_type: "text/html"
on the Controller render, since the response comes with the type"text/vnd.turbo-stream.html"
.System configuration
Rails version: 7.0.3.1
Ruby version: 3.1.2
Gem version: 2.61.1
Turbo rails version: 1.1.1
The text was updated successfully, but these errors were encountered: