-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Description:
When using the default comment-list.blade.php view, the Livewire component key is set to $comment->getContentHash(). This causes “Snapshot missing on Livewire component” errors if a comment with the same content is submitted or when the comment content changes.
Steps to Reproduce:
Publish the Commentions views.
Keep :key="$comment->getContentHash()" in the @foreach loop rendering comments.
Submit a comment identical to an existing comment.
Livewire throws: Snapshot missing on Livewire component with id:
Expected Behavior:
Livewire should correctly track each comment component without snapshot errors.
Workaround / Fix:
Replacing
:key="$comment->getContentHash()"
with
:key="$comment->getId()"
in the @foreach loop fixes the snapshot issue. This ensures a stable key for each comment component.
Final code:
@foreach ($this->comments as $comment)
<livewire:commentions::comment
:key="$comment->getId()"
:comment="$comment"
:mentionables="$mentionables" />
@endforeach
Versions:
Filament: ^4.0
Filament Commentions: ^0.7.4
Livewire: ^3.6
Laravel: ^12.0
PHP: 8.2