diff --git a/apps/web/src/components/editor/manager.ts b/apps/web/src/components/editor/manager.ts index 0c8d6ef71..c425dfb51 100644 --- a/apps/web/src/components/editor/manager.ts +++ b/apps/web/src/components/editor/manager.ts @@ -61,9 +61,11 @@ class EditorManager extends BaseStore { | ((oldState: EditorContext) => Partial) ) => { this.set((state) => { + const oldState = state.editors[id]; + if (!oldState) return; const newPartialState = - typeof partial === "function" ? partial(state.editors[id]) : partial; - state.editors[id] = { ...state.editors[id], ...newPartialState }; + typeof partial === "function" ? partial(oldState) : partial; + state.editors[id] = { ...oldState, ...newPartialState }; }); };