Skip to content

Commit

Permalink
fix: Mentions showing usernames instead of names on smaller screens (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh authored Oct 27, 2023
1 parent a5f79eb commit c2f3376
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-plums-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/gazzodown": patch
---

fixed an issue with mentions showing usernames instead of names on smaller screens
7 changes: 2 additions & 5 deletions packages/gazzodown/src/mentions/UserMentionElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'>
Expand Down Expand Up @@ -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>
);
};
Expand Down

0 comments on commit c2f3376

Please sign in to comment.