aboutsummaryrefslogtreecommitdiff
path: root/src/components/emoji-input/emoji-input.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/emoji-input/emoji-input.js')
-rw-r--r--src/components/emoji-input/emoji-input.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/components/emoji-input/emoji-input.js b/src/components/emoji-input/emoji-input.js
index 8f7598ca..99dba1cb 100644
--- a/src/components/emoji-input/emoji-input.js
+++ b/src/components/emoji-input/emoji-input.js
@@ -110,6 +110,25 @@ const EmojiInput = {
const newValue = this.value.substr(0, this.caret) + emoji + this.value.substr(this.caret)
this.$refs.input.focus()
this.$emit('input', newValue)
+ this.caret += emoji.length
+ setTimeout(() => {
+ this.updateCaretPos()
+ })
+ },
+ updateCaretPos () {
+ const elem = this.$refs.input
+ if (elem.createTextRange) {
+ const range = elem.createTextRange()
+ range.move('character', this.caret)
+ range.select()
+ } else {
+ if (elem.selectionStart) {
+ elem.focus()
+ elem.setSelectionRange(this.caret, this.caret)
+ } else {
+ elem.focus()
+ }
+ }
}
}
}