From 0d7d8e9f33b3cf468ea18a795ff5f429b9bc9d62 Mon Sep 17 00:00:00 2001 From: eugenijm Date: Sat, 30 May 2020 20:26:18 +0300 Subject: [PATCH] Submit on enter fixes --- src/components/post_status_form/post_status_form.js | 6 +++++- src/components/post_status_form/post_status_form.vue | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index dd9f71d0..e15143a3 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -177,10 +177,14 @@ const PostStatusForm = { ...mapGetters(['mergedConfig']) }, methods: { - postStatus (newStatus, opts = {}) { + postStatus (event, newStatus, opts = {}) { if (this.posting) { return } if (this.submitDisabled) { return } if (this.emojiInputShown) { return } + if (this.submitOnEnter) { + event.stopPropagation() + event.preventDefault() + } if (opts.control && this.submitOnEnter) { newStatus.status = `${newStatus.status}\n` return diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 53f745bd..2ddfd32f 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -96,9 +96,9 @@ :disabled="posting" class="form-post-body" :class="{ 'scrollable-form': !!maxHeight }" - @keydown.exact.stop.prevent.enter="submitOnEnter && postStatus(newStatus)" - @keydown.meta.enter="postStatus(newStatus, { control: true })" - @keyup.ctrl.enter="postStatus(newStatus)" + @keydown.exact.enter="submitOnEnter && postStatus($event, newStatus)" + @keydown.meta.enter="postStatus($event, newStatus, { control: true })" + @keyup.ctrl.enter="postStatus($event, newStatus)" @drop="fileDrop" @dragover.prevent="fileDrag" @input="resize" @@ -218,8 +218,8 @@ v-else :disabled="submitDisabled" class="btn btn-default" - @touchstart.stop.prevent="postStatus(newStatus)" - @mousedown.stop.prevent="postStatus(newStatus)" + @touchstart.stop.prevent="postStatus($event, newStatus)" + @mousedown.stop.prevent="postStatus($event, newStatus)" > {{ $t('general.submit') }}