From bde212d432b026852e84b85cba587a7948c80d7a Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 3 Nov 2023 12:36:20 +0100 Subject: [PATCH] fix(editor): change description when switching between tasks --- src/components/input/editor/TipTap.vue | 4 ++-- src/components/tasks/partials/description.vue | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/input/editor/TipTap.vue b/src/components/input/editor/TipTap.vue index eada5dcf8..cb35c4b61 100644 --- a/src/components/input/editor/TipTap.vue +++ b/src/components/input/editor/TipTap.vue @@ -365,14 +365,14 @@ const editor = useEditor({ watch( () => modelValue, value => { - inputHTML.value = modelValue + inputHTML.value = value if (!editor?.value) return if (editor.value.getHTML() === value) { return } - + editor.value.commands.setContent(value, false) }, ) diff --git a/src/components/tasks/partials/description.vue b/src/components/tasks/partials/description.vue index 78b5753fb..92331c0e7 100644 --- a/src/components/tasks/partials/description.vue +++ b/src/components/tasks/partials/description.vue @@ -22,10 +22,10 @@ :placeholder="$t('task.description.placeholder')" :show-save="true" edit-shortcut="e" - v-model="task.description" + v-model="description" @update:model-value="saveWithDelay" @save="save" - :initial-mode="isEditorContentEmpty(task.description) ? 'preview' : 'edit'" + :initial-mode="isEditorContentEmpty(description) ? 'preview' : 'edit'" /> @@ -55,7 +55,7 @@ const { const emit = defineEmits(['update:modelValue']) -const task = ref(new TaskModel()) +const description = ref('') const saved = ref(false) // Since loading is global state, this variable ensures we're only showing the saving icon when saving the description. @@ -65,9 +65,9 @@ const taskStore = useTaskStore() const loading = computed(() => taskStore.isLoading) watch( - () => modelValue, - (value) => { - task.value = value + () => modelValue.description, + value => { + description.value = value }, {immediate: true}, ) @@ -93,8 +93,11 @@ async function save() { try { // FIXME: don't update state from internal. - task.value = await taskStore.update(task.value) - emit('update:modelValue', task.value) + const updated = await taskStore.update({ + ...modelValue, + description: description.value, + }) + emit('update:modelValue', updated) saved.value = true setTimeout(() => {