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

v2.0.8 introduced issue where broadcast_remove_to requires render: false #679

Closed
JamesChevalier opened this issue Sep 18, 2024 · 1 comment · Fixed by #680
Closed

v2.0.8 introduced issue where broadcast_remove_to requires render: false #679

JamesChevalier opened this issue Sep 18, 2024 · 1 comment · Fixed by #680

Comments

@JamesChevalier
Copy link

v2.0.8 and v2.0.9 contain an issue where broadcast_remove_to requires render: false

For example:
after_destroy -> { broadcast_remove_to("#{user_id}-activities") }
throws "ActionView::MissingTemplate: Missing partial" errors unless it's rewritten to
after_destroy -> { broadcast_remove_to("#{user_id}-activities", render: false) }

Introduced in #511
Initial commit: 5d6e604
Rebase commit: 76f492a

Code in question:

def broadcast_remove_to(*streamables, **rendering)
Turbo::StreamsChannel.broadcast_remove_to(*streamables, **extract_options_and_add_target(rendering, target: self))
end
# Same as <tt>#broadcast_remove_to</tt>, but the designated stream is automatically set to the current model.
def broadcast_remove(**rendering)
broadcast_remove_to self, **rendering
end

seanpdoyle added a commit to seanpdoyle/turbo-rails that referenced this issue Sep 18, 2024
Closes [hotwired#679][]

Prior to this change, calls to
`Turbo::Streams::Broadcasts#broadcast_remove_to` would render a
view partial that corresponds to the model *regardless* of whether or
not the contents of that render would be included in the broadcast
`<turbo-stream>` element.

Not only is it wasteful to render HTML and then do nothing with it, it
also poses the risk of failing due to errors raised during the rendering
process.

This commit restructures the contents of the
`Turbo::Streams::Broadcasts#broadcast_action_to` method to skip
extraneous rendering if `render: false` is passed. In addition, it
ensures that calls to `broadcast_remove_to` pass `render: false` by
default.

[hotwired#679]: hotwired#679
@seanpdoyle
Copy link
Contributor

@JamesChevalier thank you for opening this issue. I've opened #680 to attempt to resolve the underlying issue.

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