feat: cancel edit mode in QuoteCard with Escape key

This commit is contained in:
Settel 2022-08-27 18:43:00 +02:00
parent 75e0d99ba9
commit 35151deb76

View File

@ -17,6 +17,7 @@
:no-html="true"
@returned="saveQuote"
@blur="saveQuote"
@keydown="keydown"
/>
</div>
</div>
@ -57,11 +58,8 @@ if (props.instantEdit) {
const deleteQuote = () => useEngine().deleteQuote(props.quote.id)
const saveQuote = async () => {
const editModeEnd = async () => {
isEditMode.value = false
if (props.quote.quote) {
useEngine().saveQuote(props.quote.id || ':new:', props.quote.quote)
}
emit('edit-end')
await useEngine().loadQuotes()
@ -74,6 +72,20 @@ const saveQuote = async () => {
}
}, 0)
}
const saveQuote = async () => {
if (props.quote.quote) {
useEngine().saveQuote(props.quote.id || ':new:', props.quote.quote)
}
await editModeEnd()
}
const keydown = async (ev: KeyboardEvent) => {
if (ev.key === 'Escape') {
await editModeEnd()
}
}
</script>
<style lang="scss">