aboutsummaryrefslogtreecommitdiff
path: root/src/components/emoji-input
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/emoji-input')
-rw-r--r--src/components/emoji-input/emoji-input.js5
-rw-r--r--src/components/emoji-input/emoji-input.vue6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/components/emoji-input/emoji-input.js b/src/components/emoji-input/emoji-input.js
index 48e89409..8f7598ca 100644
--- a/src/components/emoji-input/emoji-input.js
+++ b/src/components/emoji-input/emoji-input.js
@@ -105,6 +105,11 @@ const EmojiInput = {
},
setCaret ({target: {selectionStart}}) {
this.caret = selectionStart
+ },
+ onEmoji (emoji) {
+ const newValue = this.value.substr(0, this.caret) + emoji + this.value.substr(this.caret)
+ this.$refs.input.focus()
+ this.$emit('input', newValue)
}
}
}
diff --git a/src/components/emoji-input/emoji-input.vue b/src/components/emoji-input/emoji-input.vue
index a1ddd7f9..151861de 100644
--- a/src/components/emoji-input/emoji-input.vue
+++ b/src/components/emoji-input/emoji-input.vue
@@ -1,6 +1,5 @@
<template>
<div class="emoji-input">
- <EmojiSelector />
<input
v-if="type !== 'textarea'"
:class="classname"
@@ -16,6 +15,7 @@
@keydown.shift.tab="cycleBackward"
@keydown.tab="cycleForward"
@keydown.enter="replaceEmoji"
+ ref="input"
/>
<textarea
v-else
@@ -31,7 +31,9 @@
@keydown.shift.tab="cycleBackward"
@keydown.tab="cycleForward"
@keydown.enter="replaceEmoji"
+ ref="input"
></textarea>
+ <EmojiSelector @emoji="onEmoji" />
<div class="autocomplete-panel" v-if="suggestions">
<div class="autocomplete-panel-body">
<div
@@ -58,6 +60,8 @@
@import '../../_variables.scss';
.emoji-input {
+ position: relative;
+
.form-control {
width: 100%;
}