From f86f4b514fcbb03bc2b156a8e6f302d8eb76a106 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 3 Jul 2019 23:08:51 +0300 Subject: [PATCH] Support compositionupdate event to properly show autocomplete popup for IMEs and android --- src/components/emoji-input/emoji-input.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/emoji-input/emoji-input.js b/src/components/emoji-input/emoji-input.js index 0955a37e..fde99320 100644 --- a/src/components/emoji-input/emoji-input.js +++ b/src/components/emoji-input/emoji-input.js @@ -104,6 +104,7 @@ const EmojiInput = { input.elm.addEventListener('keyup', this.onKeyUp) input.elm.addEventListener('keydown', this.onKeyDown) input.elm.addEventListener('transitionend', this.onTransition) + input.elm.addEventListener('compositionupdate', this.onCompositionUpdate) }, unmounted () { const { input } = this @@ -114,6 +115,7 @@ const EmojiInput = { input.elm.removeEventListener('keyup', this.onKeyUp) input.elm.removeEventListener('keydown', this.onKeyDown) input.elm.removeEventListener('transitionend', this.onTransition) + input.elm.removeEventListener('compositionupdate', this.onCompositionUpdate) } }, methods: { @@ -216,6 +218,12 @@ const EmojiInput = { } }, onInput (e) { + this.setCaret(e) + this.$emit('input', e.target.value) + }, + onCompositionUpdate (e) { + this.setCaret(e) + this.resize() this.$emit('input', e.target.value) }, setCaret ({ target: { selectionStart } }) {