Closed davidgut closed 1 year ago
Hey, interesting. Taking a look at it now.
I've tried rendering the pending broadcast right away and that seems to work:
> $chirp->broadcastAppend()->targets('.chirps-list')->render()
= Illuminate\Support\HtmlString {#4814
html: """
<turbo-stream targets=".chirps-list" action="append">\n
<template><turbo-frame\n
id="chirp_6"\n
Same with using broadcastAppendTo()
:
> $chirp->broadcastAppendTo(User::first())->targets('.chirps-list')->render()
= Illuminate\Support\HtmlString {#4818
html: """
<turbo-stream targets=".chirps-list" action="append">\n
<template><turbo-frame\n
Taking a look at the broadcast job.
I tried instantiating the job manually and rendering the event it generates, and it works:
> $pending = $chirp->broadcastAppendTo(User::first())->targets('.chirps-list')->later()
> $job = new Tonysm\TurboLaravel\Jobs\BroadcastAction($pending->channels, $pending->action, $pending->target, $pending->targets, $pending->partialView, $pending->partialData, $pending->inlineContent, $pending->escapeInlineContent, $pending->attributes, null);
> $job->asEvent()->render()
= """
<turbo-stream targets=".chirps-list" action="append">\n
@davidgut Can you try again after running php artisan view:clear
? Did you upgrade the package recently? It may be that you upgraded the package and the component views were already cached.
The issue was I had an old turbo-frame blade file in my views/vendor/turbo-laravel folder, namely views/vendor/turbo-laravel/turbo-stream.blade.php, from an early version of this package. What solved the issue was deleting this folder.
Thank you.
Hi,
When attempting to broadcast a Turbo Stream with multiple targets, the generated Turbo Stream misses the
targets="..."
attribute.The code above creates the following Turbo stream:
<turbo-stream target="" action="update">
Expected result:
<turbo-stream targets=".notifications-ping" action="update">
I've looked into the underlying code but can't see where it "goes missing".
Running PHP 8.1.2, Laravel 9.0 and hotwired/turbo-laravel 1.10.