diff --git a/src/editor/model/Editor.ts b/src/editor/model/Editor.ts index 3fb12e22f..90d6a0fa9 100644 --- a/src/editor/model/Editor.ts +++ b/src/editor/model/Editor.ts @@ -2,7 +2,7 @@ import { isUndefined, isArray, contains, toArray, keys, bindAll } from 'undersco import Backbone from 'backbone'; import $ from '../../utils/cash-dom'; import Extender from '../../utils/extender'; -import { getModel, hasWin, isEmptyObj } from '../../utils/mixins'; +import { getModel, hasWin, isEmptyObj, wait } from '../../utils/mixins'; import { AddOptions, Model } from '../../common'; import Selected from './Selected'; import FrameView from '../../canvas/view/FrameView'; @@ -835,6 +835,8 @@ export default class EditorModel extends Model { async load(options?: any) { const result = await this.Storage.load(options); this.loadData(result); + // Wait in order to properly update the dirty counter (#5385) + await wait(); return result; } diff --git a/src/utils/mixins.ts b/src/utils/mixins.ts index 0b75b6bbf..da205a310 100644 --- a/src/utils/mixins.ts +++ b/src/utils/mixins.ts @@ -5,6 +5,8 @@ import { isTextNode } from './dom'; import Component from '../dom_components/model/Component'; import { ObjectAny } from '../common'; +export const wait = (mls: number = 0) => new Promise(res => setTimeout(res, mls)); + export const isDef = (value: any) => typeof value !== 'undefined'; export const hasWin = () => typeof window !== 'undefined';