#266 - Reset editor state when initialising a new note to ensure clean reinitialization
authorAdam Dullage <redacted>
Tue, 3 Dec 2024 12:43:38 +0000 (12:43 +0000)
committerAdam Dullage <redacted>
Tue, 3 Dec 2024 12:43:38 +0000 (12:43 +0000)
client/views/Note.vue

index d514cdfd41555d64e97856311c43aa26d8275820..471267ea8145fb6aafcb2cafc1b29927823c621e 100644 (file)
@@ -123,7 +123,7 @@ import { mdiNoteOffOutline } from "@mdi/js";
 import { mdilContentSave, mdilDelete } from "@mdi/light-js";
 import Mousetrap from "mousetrap";
 import { useToast } from "primevue/usetoast";
-import { computed, onMounted, ref, watch } from "vue";
+import { computed, onMounted, ref, watch, nextTick } from "vue";
 import { useRouter } from "vue-router";
 
 import {
@@ -192,8 +192,14 @@ function init() {
   } else {
     newTitle.value = "";
     note.value = new Note();
-    editHandler();
-    loadingIndicator.value.setLoaded();
+    // Set the editMode to false to close any existing editors.
+    // This ensures the editor is cleanly reinitialised in an empty state.
+    // Simple fix for #266 without requiring a full re-work of the logic.
+    editMode.value = false;
+    nextTick(() => {
+      editHandler();
+      loadingIndicator.value.setLoaded();
+    });
   }
 }
 
git clone https://git.99rst.org/PROJECT