Skip to content

Commit 8fc7b7f

Browse files
Livewire 4 fixes (#2038)
* refactor: simplify parent component retrieval in LazyChild * refactor: remove unused variable in getComponentAlias method
1 parent 88bf56b commit 8fc7b7f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Livewire/LazyChild.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class LazyChild extends Component
4343

4444
public function actionsFromView(mixed $row): ?View
4545
{
46-
/** @var string $parentComponent */
47-
$parentComponent = app(ComponentRegistry::class)->getClass($this->parentName);
46+
$parentComponent = $this->getComponentAlias();
4847

4948
if (method_exists($parentComponent, 'actionsFromView')) {
5049
return app($parentComponent)->actionsFromView($row);
@@ -55,20 +54,28 @@ public function actionsFromView(mixed $row): ?View
5554

5655
public function shouldShowEditOnClick(array|Column|stdClass $column, mixed $row): bool
5756
{
58-
/** @var string $parentComponent */
59-
$parentComponent = app(ComponentRegistry::class)->getClass($this->parentName);
57+
$parentComponent = $this->getComponentAlias();
6058

6159
return app($parentComponent)->shouldShowEditOnClick($column, $row);
6260
}
6361

6462
public function shouldShowToggleable(array|Column|stdClass $column, mixed $row): bool
6563
{
66-
/** @var string $parentComponent */
67-
$parentComponent = app(ComponentRegistry::class)->getClass($this->parentName);
64+
$parentComponent = $this->getComponentAlias();
6865

6966
return app($parentComponent)->shouldShowToggleable($column, $row);
7067
}
7168

69+
private function getComponentAlias(): string
70+
{
71+
if (app()->has(ComponentRegistry::class)) {
72+
73+
return app(ComponentRegistry::class)->getClass($this->parentName);
74+
}
75+
76+
return app('livewire.finder')->resolveClassComponentClassName($this->parentName);
77+
}
78+
7279
public function render(): View
7380
{
7481
return view('livewire-powergrid::livewire.lazy-child');

0 commit comments

Comments
 (0)