From 32aa7bb5405d5890a266a33ab1b0aed33c624083 Mon Sep 17 00:00:00 2001 From: Thomas Frei <7283497+thfrei@users.noreply.github.com> Date: Sun, 10 Apr 2022 22:02:19 +0200 Subject: [PATCH] ensure that fresh note has empty scene, no bleeding --- .../app/widgets/type_widgets/canvas_note.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/type_widgets/canvas_note.js b/src/public/app/widgets/type_widgets/canvas_note.js index 3c594dbd8..1f9e6c507 100644 --- a/src/public/app/widgets/type_widgets/canvas_note.js +++ b/src/public/app/widgets/type_widgets/canvas_note.js @@ -152,10 +152,25 @@ export default class ExcalidrawTypeWidget extends TypeWidget { await sleep(200); } + /** + * new and empty note - make sure that canvas is empty. + * If we do not set it manually, we occasionally get some "bleeding" from another + * note into this fresh note. Probably due to that this note-instance does not get + * newly instantiated? + */ + if (this.excalidrawRef.current && noteComplement.content === "") { + const sceneData = { + elements: [], + appState: {}, + collaborators: [] + }; + + this.excalidrawRef.current.updateScene(sceneData); + } /** * load saved content into excalidraw canvas */ - if (this.excalidrawRef.current && noteComplement.content) { + else if (this.excalidrawRef.current && noteComplement.content) { try { const content = JSON.parse(noteComplement.content || "");