From eec8eec03cb64e0f963d77da672ad671d582d992 Mon Sep 17 00:00:00 2001 From: Sandro Domianidze Date: Mon, 21 Apr 2025 19:17:25 +0400 Subject: [PATCH] fix(repeater): bubble afterStateUpdated to parents --- packages/forms/src/Components/Repeater.php | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/forms/src/Components/Repeater.php b/packages/forms/src/Components/Repeater.php index a49e432817..b9db60da8a 100644 --- a/packages/forms/src/Components/Repeater.php +++ b/packages/forms/src/Components/Repeater.php @@ -162,6 +162,21 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract }); } + protected function callAfterStateUpdatedOnParents(Component $component, bool $isLive = false): void + { + if (! $isLive && ! $component->isLive()) { + return; + } + + $parent = $component->getContainer()->getParentComponent(); + + if ($parent) { + $parent->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($parent, true); + } + } + public function getAddAction(): Action { $action = Action::make($this->getAddActionName()) @@ -185,6 +200,8 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract $component->collapsed(false, shouldMakeComponentCollapsible: false); $component->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($component); }) ->button() ->size(ActionSize::Small) @@ -260,6 +277,8 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract $component->collapsed(false, shouldMakeComponentCollapsible: false); $component->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($component); }) ->button() ->size(ActionSize::Small) @@ -320,6 +339,8 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract $component->collapsed(false, shouldMakeComponentCollapsible: false); $component->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($component); }) ->iconButton() ->size(ActionSize::Small) @@ -359,6 +380,8 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract $component->state($items); $component->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($component); }) ->iconButton() ->size(ActionSize::Small) @@ -397,6 +420,8 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract $component->state($items); $component->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($component); }) ->iconButton() ->size(ActionSize::Small) @@ -435,6 +460,8 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract $component->state($items); $component->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($component); }) ->iconButton() ->size(ActionSize::Small) @@ -476,6 +503,8 @@ class Repeater extends Field implements Contracts\CanConcealComponents, Contract $component->state($items); $component->callAfterStateUpdated(); + + $this->callAfterStateUpdatedOnParents($component); }) ->livewireClickHandlerEnabled(false) ->iconButton()