From 5a02e3d73ec58d37ad1c4d5734717da4da24e5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sat, 21 Mar 2026 17:34:37 +0100 Subject: [PATCH] nicolium: a terrible fix for 'emoji in display name gets truncated on hover' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- .../components/panels/profile-info-panel.tsx | 2 +- .../nicolium/src/features/emoji/emojify.tsx | 43 +++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/packages/nicolium/src/components/panels/profile-info-panel.tsx b/packages/nicolium/src/components/panels/profile-info-panel.tsx index 568b51b94..bf5a8381b 100644 --- a/packages/nicolium/src/components/panels/profile-info-panel.tsx +++ b/packages/nicolium/src/components/panels/profile-info-panel.tsx @@ -180,7 +180,7 @@ const ProfileInfoPanel: React.FC = ({ account, username }) => {account.deactivated ? ( ) : ( - + )} diff --git a/packages/nicolium/src/features/emoji/emojify.tsx b/packages/nicolium/src/features/emoji/emojify.tsx index 14af8ff6b..528bb27ff 100644 --- a/packages/nicolium/src/features/emoji/emojify.tsx +++ b/packages/nicolium/src/features/emoji/emojify.tsx @@ -18,16 +18,22 @@ interface IMaybeEmoji { text: string; emojis: Record; nyaize: boolean; + truncated: boolean; } -const MaybeEmoji: React.FC = ({ text, emojis, nyaize: shouldNyaize }) => { +const MaybeEmoji: React.FC = ({ text, emojis, nyaize: shouldNyaize, truncated }) => { if (text.length < 3) return text; if (text in emojis) { const emoji = emojis[text]; const filename = emoji.static_url; if (filename?.length > 0) { - return ; + const emoji = ; + if (truncated) { + return {emoji}; + } else { + return emoji; + } } } @@ -38,10 +44,11 @@ interface IEmojify { text: string; emojis?: Array | Record; nyaize?: boolean; + truncated?: boolean; } const Emojify: React.FC = React.memo( - ({ text, emojis = {}, nyaize: shouldNyaize = false }) => { + ({ text, emojis = {}, nyaize: shouldNyaize = false, truncated = false }) => { const { disableUserProvidedMedia, systemEmojiFont } = useSettings(); if (Array.isArray(emojis)) emojis = makeEmojiMap(emojis); @@ -73,7 +80,7 @@ const Emojify: React.FC = React.memo( const { unified, shortcode } = unicodeMapping[c]; - nodes.push( + const emoji = ( = React.memo( alt={c} title={`:${shortcode}:`} src={joinPublicPath(`packs/emoji/${unified}.svg`)} - />, + /> ); + + if (truncated) { + nodes.push({emoji}); + } else { + nodes.push(emoji); + } } else if (!systemEmojiFont && unqualified in unicodeMapping) { clearStack(); const { unified, shortcode } = unicodeMapping[unqualified]; - nodes.push( + const emoji = ( = React.memo( alt={unqualified} title={`:${shortcode}:`} src={joinPublicPath(`packs/emoji/${unified}.svg`)} - />, + /> ); + + if (truncated) { + nodes.push({emoji}); + } else { + nodes.push(emoji); + } } else if (!disableUserProvidedMedia && c === ':') { if (!open) { clearStack(); @@ -107,7 +126,15 @@ const Emojify: React.FC = React.memo( // we see another : we convert it and clear the stack buffer if (open) { - nodes.push(); + nodes.push( + , + ); stack = ''; }