fix(repeater): bubble afterStateUpdated to parents

This commit is contained in:
Sandro Domianidze
2025-04-21 19:17:25 +04:00
parent 38b78b3a67
commit eec8eec03c
@@ -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()