Skip to content

Commit 62a8f69

Browse files
authored
Merge pull request #98 from kirschbaum-development/fix/77-nested-form-modal
fix: drop nested `<form>` wrapper from comments composer (#77)
2 parents 8f7771f + f0670d0 commit 62a8f69

8 files changed

Lines changed: 23 additions & 2 deletions

File tree

resources/lang/ar/comments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return [
44
'label' => 'التعليقات',
55
'placeholder' => 'اكتب تعليقك…',
6+
'add_comment' => 'أضف تعليقًا',
67
'no_comments_yet' => 'لا توجد تعليقات .',
78

89
'user_avatar_alt' => 'صورة المستخدم ',

resources/lang/en/comments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return [
44
'label' => 'Comments',
55
'placeholder' => 'Type your comment…',
6+
'add_comment' => 'Add a comment',
67
'no_comments_yet' => 'No comments yet.',
78

89
'user_avatar_alt' => 'User Avatar',

resources/lang/es/comments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return [
44
'label' => 'Comentarios',
55
'placeholder' => 'Escribe tu comentario...',
6+
'add_comment' => 'Añadir un comentario',
67
'no_comments_yet' => 'Aún no hay comentarios.',
78

89
'user_avatar_alt' => 'Avatar de usuario',

resources/lang/fr/comments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return [
44
'label' => 'Commentaires',
55
'placeholder' => 'Rédiger votre commentaire...',
6+
'add_comment' => 'Ajouter un commentaire',
67
'no_comments_yet' => 'Aucun commentaire pour le moment.',
78

89
'user_avatar_alt' => 'Avatar de l\'utilisateur',

resources/lang/nl/comments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
return [
44
'label' => 'Opmerkingen',
5+
'add_comment' => 'Een opmerking toevoegen',
56
'no_comments_yet' => 'Nog geen opmerkingen.',
67

78
'user_avatar_alt' => 'Profielfoto',

resources/lang/ro/comments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
return [
44
'label' => 'Comentarii',
55
'placeholder' => 'Scrie comentariul tău...',
6+
'add_comment' => 'Adaugă un comentariu',
67
'no_comments_yet' => 'Niciun comentariu încă.',
78

89
'user_avatar_alt' => 'Avatar',

resources/views/comments.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{{-- Main Comments Area --}}
55
<div class="comm:flex-1 comm:space-y-2">
66
@if (Config::resolveAuthenticatedUser()?->can('create', Config::getCommentModel()))
7-
<form wire:submit.prevent="save" x-cloak>
7+
<div x-cloak role="form" aria-label="{{ __('commentions::comments.add_comment') }}">
88
{{-- tiptap editor --}}
99
<div class="comm:relative tip-tap-container comm:mb-2" x-on:click="wasFocused = true" wire:ignore>
1010
<div
@@ -29,7 +29,7 @@
2929
>{{ __('commentions::comments.cancel') }}</x-filament::button>
3030
</div>
3131
</template>
32-
</form>
32+
</div>
3333
@endif
3434

3535
<livewire:dynamic-component

tests/Livewire/CommentsTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@
8383
Event::assertNotDispatched(CommentWasCreatedEvent::class);
8484
});
8585

86+
test('comments composer does not render a form element', function () {
87+
/** @var User $user */
88+
$user = User::factory()->create();
89+
actingAs($user);
90+
91+
$post = Post::factory()->create();
92+
93+
livewire(Comments::class, [
94+
'record' => $post,
95+
])
96+
->assertDontSeeHtml('<form')
97+
->assertSeeHtml('role="form"')
98+
->assertSeeHtml('wire:click="save"');
99+
});
100+
86101
test('comments editor includes prefixed component alias', function () {
87102
/** @var User $user */
88103
$user = User::factory()->create();

0 commit comments

Comments
 (0)