diff --git a/admin-lehrer/components/grid-editor/useGridEditor.ts b/admin-lehrer/components/grid-editor/useGridEditor.ts index a689d98..9308dc5 100644 --- a/admin-lehrer/components/grid-editor/useGridEditor.ts +++ b/admin-lehrer/components/grid-editor/useGridEditor.ts @@ -105,10 +105,11 @@ export function useGridEditor(sessionId: string | null) { // We call the API directly with the new values instead of going through // the buildGrid callback, which may still close over stale state due to // React's asynchronous state batching. - const initialLoadDone = useRef(false) + const mountedRef = useRef(false) useEffect(() => { - if (!initialLoadDone.current) { - if (grid) initialLoadDone.current = true + if (!mountedRef.current) { + // Skip the first trigger (component mount) — don't rebuild yet + mountedRef.current = true return } if (!sessionId) return