Skip to content

fix: typing animation displaying emojis #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colin-woon
Copy link

Reason:
The root cause is in the [TypingAnimation.tsx] component, specifically within the useEffect hook responsible for the typing logic. It iterates through the string using children.length and builds the displayed text using children.substring(0, i + 1). These JavaScript string methods operate on UTF-16 code units, not grapheme clusters. Emojis often consist of multiple code units, causing them to be split incorrectly.

Fix:
Split the input string into an array of grapheme clusters using const graphemes = Array.from(children);.
Iterate based on graphemes.length.
Reconstruct the displayed text using setDisplayedText(graphemes.slice(0, i + 1).join(""));.
This ensures that each "visible character," including emojis, is treated as a single unit.

typing_animation_bug.mp4
typing_animation_fix.mp4

Copy link

vercel bot commented May 20, 2025

@colin-woon is attempting to deploy a commit to the product-studio Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant