fix: Mentions showing usernames instead of names on smaller screens (#30705)

pull/30706/head^2
gabriellsh 2 years ago committed by GitHub
parent a5f79eb6ab
commit c2f337664e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .changeset/fuzzy-plums-travel.md
  2. 7
      packages/gazzodown/src/mentions/UserMentionElement.tsx

@ -0,0 +1,5 @@
---
"@rocket.chat/gazzodown": patch
---
fixed an issue with mentions showing usernames instead of names on smaller screens

@ -13,14 +13,11 @@ const handleUserMention = (mention: string | undefined, withSymbol: boolean | un
const UserMentionElement = ({ mention }: UserMentionElementProps): ReactElement => {
const t = useTranslation();
const { resolveUserMention, onUserMentionClick, isMobile, ownUserId, useRealName, showMentionSymbol } =
useContext(MarkupInteractionContext);
const { resolveUserMention, onUserMentionClick, ownUserId, useRealName, showMentionSymbol } = useContext(MarkupInteractionContext);
const resolved = useMemo(() => resolveUserMention?.(mention), [mention, resolveUserMention]);
const handleClick = useMemo(() => (resolved ? onUserMentionClick?.(resolved) : undefined), [resolved, onUserMentionClick]);
const showRealName = useRealName && !isMobile;
if (mention === 'all') {
return (
<Message.Highlight title={t('Mentions_all_room_members')} variant='relevant'>
@ -49,7 +46,7 @@ const UserMentionElement = ({ mention }: UserMentionElementProps): ReactElement
onClick={handleClick}
data-uid={resolved._id}
>
{handleUserMention((showRealName ? resolved.name : resolved.username) ?? mention, showMentionSymbol)}
{handleUserMention((useRealName ? resolved.name : resolved.username) ?? mention, showMentionSymbol)}
</Message.Highlight>
);
};

Loading…
Cancel
Save