refactor: move editor cancelling into function

This commit is contained in:
Daniel Pantle 2024-10-01 16:14:57 +02:00
parent 360a72d639
commit fc967884d5

@ -30,7 +30,7 @@
:spellcheck="false"
@blur="save(($event.target as HTMLInputElement).textContent as string)"
@keydown.enter.prevent.stop="($event.target as HTMLInputElement).blur()"
@keydown.esc.prevent.stop="($event.target as HTMLInputElement).textContent = task.title; ($event.target as HTMLInputElement).blur()"
@keydown.esc.prevent.stop="cancel($event.target as HTMLInputElement)"
>
{{ task.title.trim() }}
</h1>
@ -134,6 +134,11 @@ async function save(title: string) {
saving.value = false
}
}
async function cancel(element: HTMLInputElement) {
element.textContent = props.task.title
element.blur()
}
</script>
<style lang="scss" scoped>