From 607a2d4a58ec70c9bc5916adc4d5d0b4a5e6de45 Mon Sep 17 00:00:00 2001 From: robbond Date: Wed, 5 Aug 2026 09:51:17 +0100 Subject: [PATCH] fix: ensure loading overlay renders during analyse --- components/scenario-form.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/scenario-form.jsx b/components/scenario-form.jsx index 14c5703..3e7447c 100644 --- a/components/scenario-form.jsx +++ b/components/scenario-form.jsx @@ -284,8 +284,8 @@ export default function ScenarioForm() { setUpdateError(null); setCurrentUnderstanding(null); - // Allow React to render the loading state before awaiting (prevents batching away with instant mocks) - await new Promise(r => setTimeout(r, 0)); + // Force a DOM flush so loading state renders before awaiting (prevents instant mocks from swallowing it) + await new Promise(r => requestAnimationFrame(() => setTimeout(r, 50))); try { const res = await submitScenarioForStartCase(MOCK_ENABLED ? mockFetch : fetch, scenario); @@ -323,8 +323,8 @@ export default function ScenarioForm() { setUpdateError(null); setLastSubmittedAnswer(answer.trim()); - // Allow React to render the loading state before awaiting (prevents batching away with instant mocks) - await new Promise(r => setTimeout(r, 0)); + // Force a DOM flush so loading state renders before awaiting (prevents instant mocks from swallowing it) + await new Promise(r => requestAnimationFrame(() => setTimeout(r, 50))); const submission = await submitAnswerForUpdateCase(MOCK_ENABLED ? mockFetch : fetch, { situationGraph: result?.situationGraph, @@ -449,7 +449,7 @@ export default function ScenarioForm() { )} {/* ── Main result workspace ─────────────────────── */} - {(status === "success" || status === "error") && ( + {((status === "success" || status === "error") && status !== "loading") && (