Repository navigation
fix: keep emoji intact in avatar initials - #3923
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
getInitialsFromName took the first UTF-16 code unit of each word, so a name that starts with an emoji or another character outside the BMP rendered a lone surrogate in UserAvatar and the reactions avatar. Take the first code point instead.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Goal
Avatar initials show a broken glyph (
�) when a user name starts with an emoji or another character outside the Basic Multilingual Plane.getInitialsFromNameusedcharAt(0), which returns a single UTF-16 code unit and splits surrogate pairs.UserAvatarandMessageUserReactionsAvatarboth use this helper.🛠 Implementation details
getInitialsFromNamenow takes the first code point of each word withArray.from(word)[0]instead ofword.charAt(0). Output for BMP names is unchanged.toUpperCase()runs on the full code point, so non-BMP letters with case mappings (for example Deseret𐐨→𐐀) are uppercased correctly.getInitialsFromNameinsrc/utils/__tests__/utils.test.ts, covering regular names, extra whitespace,numberOfInitials, and non-BMP first characters.🎨 UI Changes
Avatar initials for a user named
😀 Smileychange from�Sto😀S. No layout change.iOS
Android
🧪 Testing
cd package && TZ=UTC npx jest src/utils/__tests__/utils.test.tsThe new test
should not split characters outside the BMP into lone surrogatesfails without the change (Expected: "😀S",Received: "�S") and passes with it.☑️ Checklist
developbranchFixes #3922