From: Adam Dullage Date: Tue, 3 Dec 2024 12:43:38 +0000 (+0000) Subject: #266 - Reset editor state when initialising a new note to ensure clean reinitialization X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=d0564a43f8ea05202de3c17afb7b6ba8d3fb8a43;p=flatnotes.git #266 - Reset editor state when initialising a new note to ensure clean reinitialization --- diff --git a/client/views/Note.vue b/client/views/Note.vue index d514cdf..471267e 100644 --- a/client/views/Note.vue +++ b/client/views/Note.vue @@ -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(); + }); } }