forked from AkkomaGang/akkoma-fe
properly position the caret after replacement
This commit is contained in:
parent
a05fd042df
commit
5f4a8dcc05
1 changed files with 9 additions and 3 deletions
|
@ -130,10 +130,16 @@ const EmojiInput = {
|
|||
const replacement = suggestion.replacement
|
||||
const newValue = Completion.replaceWord(this.value, this.wordAtCaret, replacement)
|
||||
this.$emit('input', newValue)
|
||||
this.caret = 0
|
||||
this.highlighted = 0
|
||||
const position = this.wordAtCaret.start + replacement.length
|
||||
|
||||
this.$nextTick(function () {
|
||||
// Re-focus inputbox after clicking suggestion
|
||||
this.input.elm.focus()
|
||||
// Set selection right after the replacement instead of the very end
|
||||
this.input.elm.setSelectionRange(position, position)
|
||||
this.caret = position
|
||||
})
|
||||
e.preventDefault()
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue