diff --git a/src/canvas/view/FrameWrapView.ts b/src/canvas/view/FrameWrapView.ts index c03bc6e42..2d7049176 100644 --- a/src/canvas/view/FrameWrapView.ts +++ b/src/canvas/view/FrameWrapView.ts @@ -85,7 +85,7 @@ export default class FrameWrapView extends ModuleView { updateOffset() { const { em, $el, frame } = this; - if (!em) return; + if (!em || em.destroyed) return; em.runDefault({ preserveSelected: 1 }); $el.removeClass(this.classAnim); frame?.model?._emitUpdated(); diff --git a/src/editor/model/Editor.ts b/src/editor/model/Editor.ts index fa5197768..c9aeed384 100644 --- a/src/editor/model/Editor.ts +++ b/src/editor/model/Editor.ts @@ -101,6 +101,7 @@ export default class EditorModel extends Model { defaultRunning = false; destroyed = false; _config: EditorConfig; + _storageTimeout?: NodeJS.Timeout; attrsOrig: any; timedInterval?: number; updateItr?: number; @@ -323,7 +324,7 @@ export default class EditorModel extends Model { postLoad(); } else { // Defer for storage load events. - setTimeout(async () => { + this._storageTimeout = setTimeout(async () => { if (projectData) { this.loadData(projectData); } else if (sm?.canAutoload()) { @@ -997,6 +998,7 @@ export default class EditorModel extends Model { // @ts-ignore const { editors = [] } = config.grapesjs || {}; const shallow = this.get('shallow'); + clearTimeout(this._storageTimeout); shallow?.destroyAll(); this.stopListening(); this.stopDefault();