소스 검색

Prevent emoji from being inserted twice

JC Brand 4 년 전
부모
커밋
bbf4c08ffd
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      src/components/emoji-picker.js

+ 6 - 0
src/components/emoji-picker.js

@@ -200,8 +200,14 @@ export default class EmojiPicker extends CustomElement {
     }
 
     onEnterPressed (ev) {
+        if (ev.emoji_keypress_handled) {
+            // Prevent the emoji from being inserted a 2nd time due to this
+            // method being called by two event handlers: onKeyDown and _onGlobalKeyDown
+            return;
+        }
         ev.preventDefault();
         ev.stopPropagation();
+        ev.emoji_keypress_handled = true;
         if (converse.emojis.shortnames.includes(ev.target.value)) {
             this.insertIntoTextArea(ev.target.value);
         } else if (this.search_results.length === 1) {