diff --git a/packages/forms/src/Components/Wizard.php b/packages/forms/src/Components/Wizard.php index 6b13de47ed..88bf07a931 100644 --- a/packages/forms/src/Components/Wizard.php +++ b/packages/forms/src/Components/Wizard.php @@ -30,7 +30,7 @@ class Wizard extends Component protected int | Closure $startStep = 1; - protected int $currentStepIndex = 0; + protected ?int $currentStepIndex = null; /** * @var view-string @@ -60,8 +60,6 @@ class Wizard extends Component { parent::setUp(); - $this->setCurrentStepIndex($this->getStartStep() - 1); - $this->registerActions([ fn (Wizard $component): Action => $component->getNextAction(), fn (Wizard $component): Action => $component->getPreviousAction(), @@ -268,7 +266,7 @@ class Wizard extends Component public function getCurrentStepIndex(): int { - return $this->currentStepIndex; + return $this->currentStepIndex ??= ($this->getStartStep() - 1); } protected function setCurrentStepIndex(int $index): static