mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 05:14:12 +03:00
🐛 Fixed unnecessary "Are you sure you want to leave?" modals
no issue - if a post was saved before the body content was edited you would get stuck with an "Are you sure you want to leave?" modal even though you had already saved - the editor saw the post as being in a dirty state because the `mobiledoc` and `scratch` value were null but after saving the `mobiledoc` value was set to an blank mobiledoc object as returned by the API - updated the `post` model save method to reset the `scratch` value if the returned `mobiledoc` no longer matches
This commit is contained in:
parent
855fd7ae80
commit
c19f5b9c51
@ -190,6 +190,19 @@ export default Model.extend(Comparable, ValidationEngine, {
|
||||
}
|
||||
}),
|
||||
|
||||
save() {
|
||||
// ensure that our scratch value used in the editor is kept in sync with
|
||||
// what we get back from the API after saving - avoids issues which cause
|
||||
// the editor to see a saved post as dirty and show a "are you sure" modal
|
||||
return this._super(...arguments).then(() => {
|
||||
if (JSON.stringify(this.mobiledoc) !== JSON.stringify(this.scratch)) {
|
||||
this.set('scratch', this.mobiledoc);
|
||||
}
|
||||
|
||||
return this;
|
||||
});
|
||||
},
|
||||
|
||||
_getPublishedAtBlogTZ() {
|
||||
let publishedAtUTC = this.publishedAtUTC;
|
||||
let publishedAtBlogDate = this.publishedAtBlogDate;
|
||||
|
Loading…
Reference in New Issue
Block a user