From d189743a9c083f15949d20efc7e73414756a7d5a Mon Sep 17 00:00:00 2001 From: ilyapashayan Date: Wed, 1 Apr 2026 01:10:13 +0400 Subject: [PATCH] fix: show user-friendly error on file upload failure (413) Livewire fires a livewire-upload-error JS event when an upload fails, including 413 responses from the server. Add x-on: Alpine listeners on the comment and reply forms to display an error message instead of silently failing. Use x-on: instead of @ shorthand to avoid Blade parsing @livewire as a directive. --- resources/views/livewire/comment-item.blade.php | 7 ++++++- resources/views/livewire/comments.blade.php | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/resources/views/livewire/comment-item.blade.php b/resources/views/livewire/comment-item.blade.php index 9a6c1d8..f6a6646 100644 --- a/resources/views/livewire/comment-item.blade.php +++ b/resources/views/livewire/comment-item.blade.php @@ -104,7 +104,11 @@ {{-- Reply form --}} @if ($isReplying) -
+
{{ $this->replyForm }} @if (!empty($replyAttachments)) @@ -120,6 +124,7 @@ @error('replyAttachments.*')

{{ $message }}

@enderror +

@endif
diff --git a/resources/views/livewire/comments.blade.php b/resources/views/livewire/comments.blade.php index 19ddf14..1087cae 100644 --- a/resources/views/livewire/comments.blade.php +++ b/resources/views/livewire/comments.blade.php @@ -2,6 +2,9 @@ @if (!\Relaticle\Comments\CommentsConfig::isBroadcastingEnabled()) wire:poll.{{ \Relaticle\Comments\CommentsConfig::getPollingInterval() }} @endif + x-data="{ uploadError: null }" + x-on:livewire-upload-error.window="uploadError = '{{ __('File upload failed. The file may be too large or an unsupported type.') }}'" + x-on:livewire-upload-start.window="uploadError = null" > {{-- Sort toggle --}}
@@ -76,6 +79,7 @@ @error('attachments.*')

{{ $message }}

@enderror +

@endif