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
This commit is contained in:
parent
da311fce9e
commit
5a25685d53
@ -110,6 +110,7 @@
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
:shadow="false"
|
:shadow="false"
|
||||||
v-cy="'saveEditor'"
|
v-cy="'saveEditor'"
|
||||||
|
:disabled="!contentHasChanged"
|
||||||
>
|
>
|
||||||
{{ $t('misc.save') }}
|
{{ $t('misc.save') }}
|
||||||
</x-button>
|
</x-button>
|
||||||
@ -288,6 +289,16 @@ const emit = defineEmits(['update:modelValue', 'save'])
|
|||||||
|
|
||||||
const internalMode = ref<Mode>('edit')
|
const internalMode = ref<Mode>('edit')
|
||||||
const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled)
|
const isEditing = computed(() => internalMode.value === 'edit' && isEditEnabled)
|
||||||
|
const contentHasChanged = ref<boolean>(false)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => internalMode.value,
|
||||||
|
mode => {
|
||||||
|
if (mode === 'preview') {
|
||||||
|
contentHasChanged.value = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
content: modelValue,
|
content: modelValue,
|
||||||
@ -308,7 +319,9 @@ const editor = useEditor({
|
|||||||
addKeyboardShortcuts() {
|
addKeyboardShortcuts() {
|
||||||
return {
|
return {
|
||||||
'Mod-Enter': () => {
|
'Mod-Enter': () => {
|
||||||
bubbleSave()
|
if(contentHasChanged.value) {
|
||||||
|
bubbleSave()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -420,6 +433,7 @@ function bubbleNow() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contentHasChanged.value = true
|
||||||
emit('update:modelValue', editor.value?.getHTML())
|
emit('update:modelValue', editor.value?.getHTML())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user