diff --git a/site/src/components/intake/steps/DOTIntakeStep.astro b/site/src/components/intake/steps/DOTIntakeStep.astro index de8de3e..8a13cbe 100644 --- a/site/src/components/intake/steps/DOTIntakeStep.astro +++ b/site/src/components/intake/steps/DOTIntakeStep.astro @@ -266,7 +266,7 @@ function showRelevantSections() { const PW = (window as any).PWIntake; - const state = PW.get(); + const state = PW?.get?.() || {}; // Get service slug from wizard element or state const wizardEl = document.querySelector(".pw-wizard[data-service]"); const pageSlug = wizardEl?.getAttribute("data-service") || ""; @@ -300,12 +300,13 @@ } } - // Show sections on DOM ready and on step-shown - if (document.readyState === "loading") { - document.addEventListener("DOMContentLoaded", showRelevantSections); - } else { + // Show sections — retry until wizard element is found + function initSections() { + const wizardEl = document.querySelector(".pw-wizard[data-service]"); + if (!wizardEl) { setTimeout(initSections, 100); return; } showRelevantSections(); } + initSections(); window.addEventListener("pw:step-shown", (evt: any) => { if (evt.detail.step !== "dot-intake") return; showRelevantSections();