Skip to content

Commit e7d3aa2

Browse files
committed
Hide attachment control until editor is focused
1 parent 82c543f commit e7d3aa2

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

resources/views/comments.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</div>
1616

1717
@if ($this->attachmentsAreEnabled())
18-
<div class="comm:mb-2 comm:space-y-1">
18+
<div class="comm:mb-2 comm:space-y-1" x-show="wasFocused" x-cloak>
1919
<label class="comm:inline-flex comm:cursor-pointer comm:items-center comm:gap-1 comm:rounded-lg comm:border comm:border-gray-300 comm:dark:border-gray-700 comm:px-2 comm:py-1 comm:text-xs comm:text-gray-600 comm:dark:text-gray-300 comm:hover:bg-gray-100 comm:dark:hover:bg-gray-800">
2020
<input type="file" class="comm:hidden" wire:model="attachments" multiple />
2121
<x-filament::icon icon="heroicon-s-paper-clip" class="comm:h-4 comm:w-4" />

tests/Livewire/CommentAttachmentTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@
6060
->assertSeeHtml('wire:model="attachments"');
6161
});
6262

63+
test('the attach control is only shown once the editor is focused', function () {
64+
$user = User::factory()->create();
65+
actingAs($user);
66+
67+
$post = Post::factory()->create();
68+
69+
livewire(Comments::class, ['record' => $post, 'attachmentsEnabled' => true])
70+
->assertSeeHtml('x-show="wasFocused"');
71+
});
72+
6373
test('deleting a comment removes its attachments and files', function () {
6474
$user = User::factory()->create();
6575
actingAs($user);

0 commit comments

Comments
 (0)