From 5a25685d53c3d965fce91da0d2fb869c6feb3a46 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 21 Jan 2024 13:44:19 +0100 Subject: [PATCH] fix(editor): don't bubble up changes when no changes were made Related https://community.vikunja.io/t/saving-an-empty-description-in-kanban-view-break-ui/1914/3 --- src/components/input/editor/TipTap.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/input/editor/TipTap.vue b/src/components/input/editor/TipTap.vue index 6f117f596..34d1f37c6 100644 --- a/src/components/input/editor/TipTap.vue +++ b/src/components/input/editor/TipTap.vue @@ -110,6 +110,7 @@ variant="secondary" :shadow="false" v-cy="'saveEditor'" + :disabled="!contentHasChanged" > {{ $t('misc.save') }} @@ -288,6 +289,16 @@ const emit = defineEmits(['update:modelValue', 'save']) const internalMode = ref('edit') const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled) +const contentHasChanged = ref(false) + +watch( + () => internalMode.value, + mode => { + if (mode === 'preview') { + contentHasChanged.value = false + } + }, +) const editor = useEditor({ content: modelValue, @@ -308,7 +319,9 @@ const editor = useEditor({ addKeyboardShortcuts() { return { 'Mod-Enter': () => { - bubbleSave() + if(contentHasChanged.value) { + bubbleSave() + } }, } }, @@ -420,6 +433,7 @@ function bubbleNow() { return } + contentHasChanged.value = true emit('update:modelValue', editor.value?.getHTML()) }