fix: emoji name is not getting rendered correctly for emojis with skin tone modifers #16119
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.
Description
In the latest version of emoji-picker library a new version of emoji.json file got added. In this json file the unicode object called "u" has the emoji unicode without the skintone modifiers. if the emoji has skin tone modifiers then its part of another object property called "v".
Example:
This is the emoji object of a boy emoji-
{ "n": [ "boy" ], "u": "1f466", "v": [ "1f466-1f3fb", "1f466-1f3fc", "1f466-1f3fd", "1f466-1f3fe", "1f466-1f3ff" ], "a": "0.6" }
As you can see the unicode object property "u" has the emoji unicode, the "v" property holds the unicode with skin modifier. But not all emoji has skin modifiers so we need to use the actual emoji unicode value as our unicode key. When a skin tone modifier emoji comes like hand emojis then we need to discard the skin modifier part of the unicode and take the rest of it and compare the unicode value with our emoji dictionary to fetch the emoji title/name. So suppose receive 1f466-1f3fb then we need to discard the 1f3fb part of it and compare only 1f466 with the emoji dictionary. The skin modifier can be any part of the unicode not just at the end, but they are fixed value set one of 1f3fb/1f3fc/1f3fd/1f3fe/1f3ff
Another fix I have done is, don't replace a hyphen from the emoji title with space if its followed by a numeric character. This is fixed the issue of thumbs down emoji title which is -1 and was displayed as 1 now its -1.
Screenshots/Screencast (for UI changes)
BEFORE
AFTER
Checklist