fix: allow loading render before awaiting (prevent React batching)
This commit is contained in:
@@ -284,6 +284,9 @@ export default function ScenarioForm() {
|
|||||||
setUpdateError(null);
|
setUpdateError(null);
|
||||||
setCurrentUnderstanding(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));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await submitScenarioForStartCase(MOCK_ENABLED ? mockFetch : fetch, scenario);
|
const res = await submitScenarioForStartCase(MOCK_ENABLED ? mockFetch : fetch, scenario);
|
||||||
|
|
||||||
@@ -320,6 +323,9 @@ export default function ScenarioForm() {
|
|||||||
setUpdateError(null);
|
setUpdateError(null);
|
||||||
setLastSubmittedAnswer(answer.trim());
|
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));
|
||||||
|
|
||||||
const submission = await submitAnswerForUpdateCase(MOCK_ENABLED ? mockFetch : fetch, {
|
const submission = await submitAnswerForUpdateCase(MOCK_ENABLED ? mockFetch : fetch, {
|
||||||
situationGraph: result?.situationGraph,
|
situationGraph: result?.situationGraph,
|
||||||
previousQuestion: result?.selectedQuestion,
|
previousQuestion: result?.selectedQuestion,
|
||||||
|
|||||||
Reference in New Issue
Block a user