From 5d9da26970a49371a4190f0555a51b6c1a312d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 16 Feb 2024 17:42:26 +0100 Subject: [PATCH] Fixes for circular referece and re-rendering --- app/Livewire/BillingPortal/Purchase.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Livewire/BillingPortal/Purchase.php b/app/Livewire/BillingPortal/Purchase.php index 8e70261fa15e..96762313a13a 100644 --- a/app/Livewire/BillingPortal/Purchase.php +++ b/app/Livewire/BillingPortal/Purchase.php @@ -52,12 +52,16 @@ class Purchase extends Component #[On('purchase.context')] public function handleContext(string $property, $value): self { + $clone = $this->context; + data_set($this->context, $property, $value); // The following may not be needed, as we can pass arround $context. // cache()->set($this->hash, $this->context); - $this->id = Str::uuid(); + if ($clone !== $this->context) { + $this->id = Str::uuid(); + } return $this; } @@ -86,6 +90,18 @@ class Purchase extends Component return $this->steps[$this->step]; } + #[Computed()] + public function componentUniqueId(): string + { + return "purchase-{$this->id}"; + } + + #[Computed()] + public function summaryUniqueId(): string + { + return "summary-{$this->id}"; + } + public function mount() { $this->id = Str::uuid();