diff --git a/resources/views/select-tree.blade.php b/resources/views/select-tree.blade.php index f963279..4fb9414 100644 --- a/resources/views/select-tree.blade.php +++ b/resources/views/select-tree.blade.php @@ -12,10 +12,10 @@
current())) ax-load="visible" @else ax-load diff --git a/src/SelectTree.php b/src/SelectTree.php index e809057..aeb1aa0 100644 --- a/src/SelectTree.php +++ b/src/SelectTree.php @@ -88,6 +88,8 @@ class SelectTree extends Field implements HasAffixActions protected Closure|array|null $prepend = null; + protected Closure|string|null $treeKey = 'treeKey'; + protected function setUp(): void { // Load the state from relationships using a callback function. @@ -145,6 +147,8 @@ protected function setUp(): void $this->suffixActions([ static fn (SelectTree $component): ?Action => $component->getCreateOptionAction(), ]); + + $this->treeKey('treeKey-'.rand()); } protected function buildTree(): Collection @@ -614,4 +618,16 @@ public function createOptionModalHeading(string|Closure|null $heading): static return $this; } + + public function treeKey(string $treeKey): static + { + $this->treeKey = $treeKey; + + return $this; + } + + public function getTreeKey(): string + { + return $this->evaluate($this->treeKey); + } }