aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2019-06-17 21:24:10 +0300
committerHenry Jameson <me@hjkos.com>2019-06-17 21:24:10 +0300
commit5f4a8dcc05a0790d5ef17d3a2df3a65d260641ee (patch)
treed8aa2b6ba94dab45ab8da70e95c38b54313ac12a /src
parenta05fd042df9e025b287f342358be6bbd4f0d5018 (diff)
properly position the caret after replacement
Diffstat (limited to 'src')
-rw-r--r--src/components/emoji-input/emoji-input.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/components/emoji-input/emoji-input.js b/src/components/emoji-input/emoji-input.js
index c425fdf5..b79d11ca 100644
--- a/src/components/emoji-input/emoji-input.js
+++ b/src/components/emoji-input/emoji-input.js
@@ -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
- // Re-focus inputbox after clicking suggestion
- this.input.elm.focus()
+ 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()
}
},