From 3c07ca0b9c48cef60d56acdd44812e20e05fc928 Mon Sep 17 00:00:00 2001 From: Dominik <6538827+bdbch@users.noreply.github.com> Date: Tue, 28 Feb 2023 10:50:43 +0100 Subject: [PATCH] fix(core): fix destroyed view causing errors on dispatchTransaction (#3799) --- .../DestroyingEditor/Vue/index.html | 0 .../DestroyingEditor/Vue/index.vue | 49 +++++++++++++++++++ packages/core/src/Editor.ts | 6 +++ 3 files changed, 55 insertions(+) create mode 100644 demos/src/Experiments/DestroyingEditor/Vue/index.html create mode 100644 demos/src/Experiments/DestroyingEditor/Vue/index.vue diff --git a/demos/src/Experiments/DestroyingEditor/Vue/index.html b/demos/src/Experiments/DestroyingEditor/Vue/index.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/demos/src/Experiments/DestroyingEditor/Vue/index.vue b/demos/src/Experiments/DestroyingEditor/Vue/index.vue new file mode 100644 index 0000000000..4d6e170dbb --- /dev/null +++ b/demos/src/Experiments/DestroyingEditor/Vue/index.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index ba545511b2..7cd43caf49 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -320,6 +320,12 @@ export class Editor extends EventEmitter { * @param transaction An editor state transaction */ private dispatchTransaction(transaction: Transaction): void { + // if the editor / the view of the editor was destroyed + // the transaction should not be dispatched as there is no view anymore. + if (this.view.isDestroyed) { + return + } + if (this.isCapturingTransaction) { if (!this.capturedTransaction) { this.capturedTransaction = transaction