mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Fixed error when deleting post (#19369)
closes https://github.com/TryGhost/Product/issues/4230 - deleting a post could cause React components to trigger save tasks during teardown which then threw errors because they attempt to set properties on a deleted model instance - added checks to the `beforeSaveTask()` to abort if the post object has been deleted
This commit is contained in:
parent
b74a611fbd
commit
4ceb5dc16b
1 changed files with 9 additions and 1 deletions
|
@ -415,7 +415,11 @@ export default class LexicalEditorController extends Controller {
|
||||||
|
|
||||||
@action
|
@action
|
||||||
handleFeatureImageCaptionBlur() {
|
handleFeatureImageCaptionBlur() {
|
||||||
if (this.post?.isDraft) {
|
if (!this.post || this.post.isDestroyed || this.post.isDestroying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.post.isDraft) {
|
||||||
this.autosaveTask.perform();
|
this.autosaveTask.perform();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,6 +619,10 @@ export default class LexicalEditorController extends Controller {
|
||||||
|
|
||||||
@task
|
@task
|
||||||
*beforeSaveTask(options = {}) {
|
*beforeSaveTask(options = {}) {
|
||||||
|
if (this.post?.isDestroyed || this.post?.isDestroying) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ensure we remove any blank cards when performing a full save
|
// ensure we remove any blank cards when performing a full save
|
||||||
if (!options.backgroundSave) {
|
if (!options.backgroundSave) {
|
||||||
// TODO: not yet implemented in react editor
|
// TODO: not yet implemented in react editor
|
||||||
|
|
Loading…
Add table
Reference in a new issue