From 53b6851a79984ba24a873e3423bb15b3fb386002 Mon Sep 17 00:00:00 2001 From: Jonas Rittershofer Date: Tue, 26 May 2020 14:37:22 +0200 Subject: [PATCH] Avoid Submit on Enter Signed-off-by: Jonas Rittershofer --- src/components/Questions/QuestionLong.vue | 6 +++- src/components/Questions/QuestionMultiple.vue | 3 +- src/components/Questions/QuestionShort.vue | 3 +- src/mixins/QuestionMixin.js | 9 ++++++ src/views/Submit.vue | 32 +++++++++++++++++-- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/components/Questions/QuestionLong.vue b/src/components/Questions/QuestionLong.vue index f3ad1f9..cca5770 100644 --- a/src/components/Questions/QuestionLong.vue +++ b/src/components/Questions/QuestionLong.vue @@ -40,7 +40,8 @@ :maxlength="maxStringLengths.answerText" minlength="1" @input="onInput" - @keydown="autoSizeText" /> + @keypress="autoSizeText" + @keydown.ctrl.enter="onKeydownCtrlEnter" /> @@ -74,6 +75,9 @@ export default { textarea.style.cssText = 'height:auto; padding:0' textarea.style.cssText = `height: ${textarea.scrollHeight + 20}px` }, + onKeydownCtrlEnter(event) { + this.$emit('keydown', event) + }, }, } diff --git a/src/components/Questions/QuestionMultiple.vue b/src/components/Questions/QuestionMultiple.vue index b433942..bb411ad 100644 --- a/src/components/Questions/QuestionMultiple.vue +++ b/src/components/Questions/QuestionMultiple.vue @@ -46,7 +46,8 @@ :name="`${id}-answer`" :required="isRequired(answer.id)" :type="isUnique ? 'radio' : 'checkbox'" - @change="onChange($event, answer.id)"> + @change="onChange($event, answer.id)" + @keydown.enter.exact.prevent="onKeydownEnter">