From c66c08fa78c257cb435626d3fffe5fdd18588445 Mon Sep 17 00:00:00 2001 From: David Gallardo Date: Fri, 8 May 2026 22:36:10 +0200 Subject: [PATCH] fix: ignore emoji when deriving avatar initials (#2167) --- apps/client/src/components/ui/custom-avatar.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/client/src/components/ui/custom-avatar.tsx b/apps/client/src/components/ui/custom-avatar.tsx index 5f38e804..ac6e8413 100644 --- a/apps/client/src/components/ui/custom-avatar.tsx +++ b/apps/client/src/components/ui/custom-avatar.tsx @@ -42,6 +42,11 @@ function pickInitialsColor(name: string) { return SAFE_INITIALS_COLORS[hashName(name) % SAFE_INITIALS_COLORS.length]; } +function sanitizeInitialsSource(name: string) { + const sanitized = name.replace(/[^\p{L}\p{N}\s]/gu, " ").trim(); + return sanitized || name; +} + export const CustomAvatar = React.forwardRef< HTMLInputElement, CustomAvatarProps @@ -49,12 +54,13 @@ export const CustomAvatar = React.forwardRef< const avatarLink = getAvatarUrl(avatarUrl, type); const resolvedColor = !color || color === "initials" ? pickInitialsColor(name ?? "") : color; + const initialsSource = sanitizeInitialsSource(name ?? ""); return (