From 5f742fb69f73fe30fd68b026372d0875d6eb2de0 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Sun, 14 Sep 2025 20:23:36 +0100 Subject: [PATCH] fix: Testing action arguments --- .../src/Concerns/InteractsWithActions.php | 1 + .../Actions/SetUpAppAuthenticationAction.php | 2 +- tests/src/Forms/Components/RepeaterTest.php | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/actions/src/Concerns/InteractsWithActions.php b/packages/actions/src/Concerns/InteractsWithActions.php index ef8b3e579d..318a88329a 100644 --- a/packages/actions/src/Concerns/InteractsWithActions.php +++ b/packages/actions/src/Concerns/InteractsWithActions.php @@ -470,6 +470,7 @@ trait InteractsWithActions continue; } + $resolvedAction->mergeArguments($action['arguments'] ?? []); $resolvedAction->nestingIndex($actionNestingIndex); $resolvedAction->boot(); diff --git a/packages/panels/src/Auth/MultiFactor/App/Actions/SetUpAppAuthenticationAction.php b/packages/panels/src/Auth/MultiFactor/App/Actions/SetUpAppAuthenticationAction.php index daf207a744..c3ec31706a 100644 --- a/packages/panels/src/Auth/MultiFactor/App/Actions/SetUpAppAuthenticationAction.php +++ b/packages/panels/src/Auth/MultiFactor/App/Actions/SetUpAppAuthenticationAction.php @@ -40,7 +40,7 @@ class SetUpAppAuthenticationAction ->color('primary') ->icon(Heroicon::LockClosed) ->link() - ->mountUsing(function (HasActions $livewire, $action) use ($appAuthentication): void { + ->mountUsing(function (HasActions $livewire) use ($appAuthentication): void { $livewire->mergeMountedActionArguments([ 'encrypted' => encrypt([ 'secret' => $appAuthentication->generateSecret(), diff --git a/tests/src/Forms/Components/RepeaterTest.php b/tests/src/Forms/Components/RepeaterTest.php index 1a9b9069b2..669d407f98 100644 --- a/tests/src/Forms/Components/RepeaterTest.php +++ b/tests/src/Forms/Components/RepeaterTest.php @@ -1,5 +1,7 @@ schemaComponent('hiddenDelete') + ->arguments(['item' => 1]); + + $deleteAction2 = TestAction::make('delete') + ->schemaComponent('hiddenDelete') + ->arguments(['item' => 2]); + + livewire(TestComponentWithRepeater::class) + ->assertActionHidden($deleteAction1) + ->assertActionVisible($deleteAction2); + + $undoRepeaterFake(); +}); + class TestComponentWithRepeater extends Livewire { public function mount(): void @@ -393,6 +413,22 @@ class TestComponentWithRepeater extends Livewire ], ], ]), + Repeater::make('hiddenDelete') + ->schema([ + TextInput::make('title'), + ]) + ->default([ + [ + 'title' => 'title 1', + ], + [ + 'title' => 'title 2', + ], + [ + 'title' => 'title 3', + ], + ]) + ->deleteAction(fn (Action $action) => $action->hidden(fn (array $arguments): bool => $arguments['item'] === 1)), ]) ->statePath('data'); }