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

Only pass :request_id option to Refresh Stream #603

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Mar 14, 2024

When rendering <turbo-stream> elements for broadcasting, omit the :request_id partial-local variable if it's blank.

If rendered partials utilize Action View strict locals, the extra variable raises an error:

unknown local :request_id

By omitting the :request_id from the
Turbo::Broadcastable#broadcast_rendering_with_defaults, it isn't passed as part of partial rendering.

Since broadcast_refresh never renders a partial itself (it builds an empty <turbo-stream action="refresh" request-id="..."></turbo-stream> element), the :request_id local variable isn't necessary.

@seanpdoyle seanpdoyle force-pushed the request-id-partial-local branch 3 times, most recently from bb56fbc to 220fc01 Compare March 15, 2024 16:53
@evdevdev
Copy link

I just ran into this same issue. Would love to see this PR merged. Is there anyway I can be helpful with it?

@seanpdoyle seanpdoyle force-pushed the request-id-partial-local branch from 220fc01 to 55cb4e4 Compare July 13, 2024 09:58
When rendering `<turbo-stream>` elements for broadcasting, **omit** the
`:request_id` partial-local variable.

When rendered partials utilize [Action View strict locals][], the extra
variable raises an error:

```
unknown local :request_id
```

By omitting the `:request_id` from the
`Turbo::Broadcastable#broadcast_rendering_with_defaults`, it isn't
passed as part of partial rendering.

Likewise, since `broadcast_refresh` never renders a partial, but instead
builds an empty `<turbo-stream action="refresh"
request-id="..."></turbo-stream>` element, the `:request_id` local
variable isn't necessary.

[Action view strict locals]: https://guides.rubyonrails.org/action_view_overview.html#strict-locals
@seanpdoyle seanpdoyle force-pushed the request-id-partial-local branch from 55cb4e4 to 77d8afa Compare July 22, 2024 13:28
@seanpdoyle
Copy link
Contributor Author

@jorgemanrubia since you're planning on cutting a new release, are you able to consider including this change as well?

@jorgemanrubia jorgemanrubia merged commit 33019f3 into hotwired:main Sep 16, 2024
15 checks passed
@jorgemanrubia
Copy link
Member

Thanks @seanpdoyle

@seanpdoyle seanpdoyle deleted the request-id-partial-local branch September 16, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants