#101 - update caret pos after emoji's inserted
This commit is contained in:
parent
b4e53576f2
commit
820a6543c7
3 changed files with 22 additions and 1 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue