From 7bfb2b4880a3d031ab7be453d184cb180e777101 Mon Sep 17 00:00:00 2001 From: Yash Gadia Date: Tue, 2 Jun 2026 01:41:00 +0530 Subject: [PATCH] fix: convert all emoji shortnames in a message, not just the last MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parseEmoji only ever converted a single shortname: it collected every `:shortname:` match but then picked the last one and ran a single `String.replace`, which swaps the first occurrence of that match. So a message with multiple shortnames left all but one as raw text, e.g. ":smile: and :heart:" rendered as ":smile: and ❤️", and ":tada: foo :tada:" converted the wrong occurrence. This is most visible on pasted text and on attachment captions (AttachmentPreview parses the whole description once on submit), since incremental typing happened to convert each shortname as it completed. emoji-toolkit's shortnameToUnicode already converts every shortname in a string and leaves unknown shortnames and plain text untouched, so the hand-rolled match/replace is both buggy and unnecessary. --- packages/react/src/lib/emoji.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/react/src/lib/emoji.js b/packages/react/src/lib/emoji.js index d438099c70..f61fee96fe 100644 --- a/packages/react/src/lib/emoji.js +++ b/packages/react/src/lib/emoji.js @@ -1,12 +1,3 @@ import emojione from 'emoji-toolkit'; -export const parseEmoji = (text) => { - const regx = /:([^:]*):/g; - const regx_data = text.match(regx); - if (regx_data) { - const result = regx_data[regx_data.length - 1]; - const d = emojione.shortnameToUnicode(result); - if (d !== undefined) text = text.replace(result, d); - } - return text; -}; +export const parseEmoji = (text) => emojione.shortnameToUnicode(text);