From 20c52a83253ed71af7e97f151880443d5f6f301d Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 18 Sep 2024 13:36:56 +0200 Subject: [PATCH] fix(editor): restore the current value, not the one from a previous task Resolves https://community.vikunja.io/t/task-description-is-overwritten-when-pressing-esc-key/2813 (cherry picked from commit acc7c9f8f5442e5008bfd86b1615a72f6f763ee8) --- frontend/src/components/input/editor/TipTap.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/input/editor/TipTap.vue b/frontend/src/components/input/editor/TipTap.vue index d5ef4e181..7e801ce5e 100644 --- a/frontend/src/components/input/editor/TipTap.vue +++ b/frontend/src/components/input/editor/TipTap.vue @@ -314,7 +314,17 @@ const internalMode = ref('preview') const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled) const contentHasChanged = ref(false) -let lastSavedState = modelValue +let lastSavedState = '' + +watch( + () => modelValue, + (newValue) => { + if (!contentHasChanged.value) { + lastSavedState = newValue + } + }, + { immediate: true }, +) watch( () => internalMode.value, @@ -576,6 +586,8 @@ function setLink(event) { } onMounted(async () => { + console.log('Component has mounted') + if (editShortcut !== '') { document.addEventListener('keydown', setFocusToEditor) }