From 2f20fd1b3c0ba36c0f3891beff8532bf95853a83 Mon Sep 17 00:00:00 2001 From: Aevann Date: Thu, 23 May 2024 23:50:06 +0300 Subject: [PATCH] remove unnecessary popups when adding # or ! to emoji --- files/assets/js/emoji_modal/inline_emoji_modal.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/files/assets/js/emoji_modal/inline_emoji_modal.js b/files/assets/js/emoji_modal/inline_emoji_modal.js index 3d6e8d552..891eac73b 100644 --- a/files/assets/js/emoji_modal/inline_emoji_modal.js +++ b/files/assets/js/emoji_modal/inline_emoji_modal.js @@ -137,12 +137,12 @@ function update_inline_emoji_modal(event) break; } - text = text.slice(0, event.target.selectionStart) + let coords = text.indexOf(' ', box_coords.pos); + + text = text.slice(0, coords === -1 ? text.length : coords) text = text.split('\n').slice(-1) - // Get current word at string, such as ":marse" or "word" - let coords = text.indexOf(' ', box_coords.pos); - current_word = /(^|\s|\+|-)([:!@][!#\w-]{2,}(?=\n|$))/.exec(text.slice(0, coords === -1 ? text.length : coords)); + current_word = /(^|\s|\+|-)([:!@][!#\w-]{2,}(?=\n|$))/.exec(text); if (current_word) { current_word = current_word[2].toLowerCase();