Submit on enter fixes

This commit is contained in:
eugenijm 2020-05-30 20:26:18 +03:00
parent f2b3d1e6b0
commit 0d7d8e9f33
2 changed files with 10 additions and 6 deletions

View file

@ -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

View file

@ -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') }}
</button>