From 7a2874bcfbed83df193219278da088058ac41e53 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Mon, 18 Mar 2024 07:44:13 +0000 Subject: [PATCH] hotfix: Action hidden check with other actions inside a group --- packages/actions/src/Concerns/CanBeHidden.php | 2 +- tests/src/Tables/ActionTest.php | 9 +++++++++ tests/src/Tables/Fixtures/PostsTable.php | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/actions/src/Concerns/CanBeHidden.php b/packages/actions/src/Concerns/CanBeHidden.php index e8c16365ff8..f11fc9661ba 100644 --- a/packages/actions/src/Concerns/CanBeHidden.php +++ b/packages/actions/src/Concerns/CanBeHidden.php @@ -94,7 +94,7 @@ public function isAuthorized(): bool public function isHidden(): bool { - if ($this->getGroup()?->isHidden()) { + if ($this->getGroup()?->baseIsHidden()) { return true; } diff --git a/tests/src/Tables/ActionTest.php b/tests/src/Tables/ActionTest.php index 5e4b859640e..a06dae42e37 100644 --- a/tests/src/Tables/ActionTest.php +++ b/tests/src/Tables/ActionTest.php @@ -31,6 +31,15 @@ ]); }); +it('can call action inside group', function () { + $post = Post::factory()->create(); + + livewire(PostsTable::class) + ->callTableAction('groupedDelete', $post); + + assertSoftDeleted($post); +}); + it('can validate an action\'s data', function () { livewire(PostsTable::class) ->callTableAction('data', data: [ diff --git a/tests/src/Tables/Fixtures/PostsTable.php b/tests/src/Tables/Fixtures/PostsTable.php index 8ae687d533c..b80908318c5 100644 --- a/tests/src/Tables/Fixtures/PostsTable.php +++ b/tests/src/Tables/Fixtures/PostsTable.php @@ -149,6 +149,11 @@ public function table(Table $table): Table Tables\Actions\DeleteAction::make(), Tables\Actions\ForceDeleteAction::make(), Tables\Actions\RestoreAction::make(), + Tables\Actions\ActionGroup::make([ + Tables\Actions\DeleteAction::make('groupedDelete'), + Tables\Actions\ForceDeleteAction::make('groupedForceDelete'), + Tables\Actions\RestoreAction::make('groupedRestore'), + ]), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(),