fix(exam): stop placeholder guide shapes flashing before template loads
Some checks failed
app-ci-deploy / test-build-deploy (push) Has been cancelled
Some checks failed
app-ci-deploy / test-build-deploy (push) Has been cancelled
seedGuide() ran in onMount via the 'else' branch while template was still null during the async fetch, creating 5 example shapes (Q1 start/end, part, response, context) that flashed on screen until the real template + PDF loaded. Only seed the guide for a genuinely-empty template after load. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
9c3a5f97cc
commit
7bd66fbaf0
@ -211,7 +211,9 @@ const ExamTemplateSetupInner: React.FC = () => {
|
|||||||
setTemplate(detail)
|
setTemplate(detail)
|
||||||
const editor = editorRef.current
|
const editor = editorRef.current
|
||||||
if (editor) {
|
if (editor) {
|
||||||
loadShapes(editor, shapesFromTemplate(detail, pageGeometriesRef.current))
|
const shapes = shapesFromTemplate(detail, pageGeometriesRef.current)
|
||||||
|
loadShapes(editor, shapes)
|
||||||
|
if (!shapes.length) seedGuide(editor)
|
||||||
bringDomainShapesToFront(editor)
|
bringDomainShapesToFront(editor)
|
||||||
}
|
}
|
||||||
setDirty(false)
|
setDirty(false)
|
||||||
@ -417,7 +419,14 @@ const ExamTemplateSetupInner: React.FC = () => {
|
|||||||
editor.store.listen(() => setDirty(true), { scope: 'document' })
|
editor.store.listen(() => setDirty(true), { scope: 'document' })
|
||||||
applyDocViewConstraints(editor, [])
|
applyDocViewConstraints(editor, [])
|
||||||
editor.resetZoom()
|
editor.resetZoom()
|
||||||
if (template) loadShapes(editor, shapesFromTemplate(template, pageGeometriesRef.current)); else seedGuide(editor)
|
// Only seed the example guide for a genuinely-empty template AFTER it has loaded.
|
||||||
|
// (Previously `else seedGuide` fired on mount while `template` was still null during
|
||||||
|
// the async fetch, flashing placeholder shapes before the real shapes/PDF rendered.)
|
||||||
|
if (template) {
|
||||||
|
const s = shapesFromTemplate(template, pageGeometriesRef.current)
|
||||||
|
loadShapes(editor, s)
|
||||||
|
if (!s.length) seedGuide(editor)
|
||||||
|
}
|
||||||
bringDomainShapesToFront(editor)
|
bringDomainShapesToFront(editor)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user