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

When rendering a Phlex view from a request with a turbo-frame header, nothing is output #174

Closed
davekaro opened this issue Mar 22, 2024 · 3 comments
Milestone

Comments

@davekaro
Copy link
Contributor

On phlex-rails main, if a request includes the turbo-frame header, and the rails app renders a Phlex view that renders the turbo frame using turbo_frame_tag output helper, nothing is rendered. This is from the behavior introduced in #154. The issue is because Phlex doesn't render the <turbo-frame> element, it doesn't know about the fragment. Possible solutions include grabbing the id positional arg and putting it in the context.fragments? Same applies for other output helpers that could have an id.

@davekaro
Copy link
Contributor Author

I created this repo to make sure nothing weird was going on in my app https://github.com/davekaro/test-phlex. It works as is, because it's using the turbo_frame tag. If you uncomment https://github.com/davekaro/test-phlex/blob/main/app/views/posts/show_view.rb#L4 and comment out line 5, this shows it not working. Not sure if helpful for testing.

@davekaro
Copy link
Contributor Author

davekaro commented Mar 22, 2024

Another issue that seems related, if you render a component before the fragment, and that component takes advantage of the fact you can just return a string in the block, then that string is still output in the response. I added this commit https://github.com/davekaro/test-phlex/commit/b7171133e21b37f8b0fd25578b4b4b6980dd9f9c that demonstrates this.

Fixed by phlex-ruby/phlex@1dcd03a

joeldrapper pushed a commit to phlex-ruby/phlex that referenced this issue Mar 22, 2024
Fixes the issue described
phlex-ruby/phlex-rails#174 (comment)

I was seeing text output before a `<turbo-frame>` in my responses, and
it was all from components that render the text "implicitly".

I found no performance difference with these changes.
@joeldrapper joeldrapper added this to the 1.2 milestone Mar 22, 2024
@joeldrapper
Copy link
Collaborator

Fixed here 9757231

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

No branches or pull requests

2 participants