From e574c2ecf7af5852c340691b90ba5216a88054bc Mon Sep 17 00:00:00 2001 From: Jackie Luo Date: Wed, 23 Mar 2016 16:48:25 -0700 Subject: [PATCH] fix(composer-emoji): Fix setBaseAndExtent bug --- .../composer-emoji/lib/emoji-composer-extension.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal_packages/composer-emoji/lib/emoji-composer-extension.jsx b/internal_packages/composer-emoji/lib/emoji-composer-extension.jsx index 55e15e78f..b1d863d33 100644 --- a/internal_packages/composer-emoji/lib/emoji-composer-extension.jsx +++ b/internal_packages/composer-emoji/lib/emoji-composer-extension.jsx @@ -12,10 +12,12 @@ class EmojiComposerExtension extends ContenteditableExtension { if (emojiOptions.length > 0) { const offset = sel.anchorOffset; if (!DOMUtils.closest(sel.anchorNode, "n1-emoji-autocomplete")) { + const anchorOffset = Math.max(sel.anchorOffset - triggerWord.length - 1, 0); editor.select(sel.anchorNode, - sel.anchorOffset - triggerWord.length - 1, + anchorOffset, sel.focusNode, - sel.focusOffset).wrapSelection("n1-emoji-autocomplete"); + sel.focusOffset) + editor.wrapSelection("n1-emoji-autocomplete"); editor.select(sel.anchorNode, offset, sel.anchorNode,