From 29d8170e9fc3aab21c9b8065fa0df9aa99db892f Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Mon, 10 Feb 2025 19:07:37 +0100 Subject: [PATCH] WIP --- packages/infolists/src/Components/Component.php | 1 + tests/src/Infolists/LivewireTest.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/infolists/src/Components/Component.php b/packages/infolists/src/Components/Component.php index 85d9e83f81..9d673f6198 100644 --- a/packages/infolists/src/Components/Component.php +++ b/packages/infolists/src/Components/Component.php @@ -36,6 +36,7 @@ class Component extends ViewComponent protected function resolveDefaultClosureDependencyForEvaluationByName(string $parameterName): array { return match ($parameterName) { + 'livewire' => [$this->getLivewire()], 'record' => [$this->getRecord()], 'state' => [$this->getState()], default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName), diff --git a/tests/src/Infolists/LivewireTest.php b/tests/src/Infolists/LivewireTest.php index 9b481daddf..857380d855 100644 --- a/tests/src/Infolists/LivewireTest.php +++ b/tests/src/Infolists/LivewireTest.php @@ -14,7 +14,9 @@ it('can inject the correct `$livewire` for infolists outside a panel', function ->assertSee('First Entry Label') ->assertSee('First Entry State') ->assertSee('Second Entry Label') - ->assertSee('Second Entry State'); + ->assertSee('Second Entry State') + ->assertSee('Third Entry Label') + ->assertSee('Third Entry State (dynamic)'); }); class TestComponentWithInfolist extends Livewire @@ -51,6 +53,13 @@ class TestComponentWithInfolist extends Livewire return [ Infolists\Components\TextEntry::make('second_entry') ->label('Second Entry Label'), + Infolists\Components\TextEntry::make('third_entry') + ->label('Third Entry Label') + ->getStateUsing(function (TestComponentWithInfolist $livewire) { + expect($livewire)->toBe($this); + + return 'Third Entry State (dynamic)'; + }), ]; }); }