fix(editor): change description when switching between tasks
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2023-11-03 12:36:20 +01:00
parent 64a8dd189b
commit bde212d432
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 13 additions and 10 deletions

View File

@ -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)
},
)

View File

@ -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'"
/>
</div>
</template>
@ -55,7 +55,7 @@ const {
const emit = defineEmits(['update:modelValue'])
const task = ref<ITask>(new TaskModel())
const description = ref<string>('')
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(() => {