-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat: append whitespace after inserting emoji #30955
Conversation
@aswin-s Could you pull the latest main? Thank you! |
@mollfpr Done! |
Also, I need help figuring out the changes for the above fix. Could you explain it more? Thanks! |
@mollfpr Here is the explanation for the changes
The earlier logic didn't consider if the diff from previous text had leading or trailing white space, there by appending an additional white space after emoji. This was fixed by checking if the diff indeed has leading or trailing white space and skipping the addition of white space if there is any. Relevant Commit: 639136a
This issue occurred because of appending whitespace immediately after a detected emoji character. However for emojis with skin tone immediately after the actual emoji there were additional unicode characters that denoted what the skin tone is. By simply adding a white space after the original emoji and then followed by the skin tone unicode characters the emoji itself got corrupted. In the fix I made sure that the entire emoji length is taken into consideration before appending white space. Relevant Commit: 6062753 |
@mollfpr Waiting for your feedback |
@aswin-s Most cases seem to be working fine, but I have one issue with pasting only an emoji next to another, which doesn't add a whitespace after it. It works fine by pasting an emoji next to a text. Simulator.Screen.Recording.-.iPhone.15.Pro.17.2.-.2024-01-22.at.21.53.30.movAlso, could you resolve the conflict? Thanks! |
@mollfpr Fixed and retested all scenarios. fix_out.mp4 |
Reviewer Checklist
Screenshots/VideosAndroid: Native30955.ANdroid.mp4Android: mWeb Chrome30955.mWeb-Chrome.mp4iOS: Native30955.iOS.moviOS: mWeb Safari30955.mWeb-Safari.movMacOS: Chrome / Safari30955.Web.mp4MacOS: Desktop30955.Desktop.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
* @param cursorPosition - position of cursor | ||
* @returns number - Length of the common suffix | ||
*/ | ||
function findCommonSuffixLength(str1: string, str2: string, cursorPosition: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like it belongs in expensify/common str.js, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment it is used only with composer and requires cursor position to exactly predict which character got appended when duplicate characters are present.
@@ -312,14 +361,8 @@ function ComposerWithSuggestions({ | |||
* @param {Boolean} shouldAddTrailSpace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we get rid of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flodnv Didn't quite get the question. Do you mean did we get rid of @param
from jsdoc? I think it has become redundant with Typescript migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I am asking: it seems that we got rid of the shouldAddTrailSpace
variable in code, and if I'm correct it seems like we should remove this @param
line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the @param
line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one more thought: is this code performing well on an input of 100k chars?
@@ -312,14 +361,8 @@ function ComposerWithSuggestions({ | |||
* @param {Boolean} shouldAddTrailSpace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I am asking: it seems that we got rid of the shouldAddTrailSpace
variable in code, and if I'm correct it seems like we should remove this @param
line?
Yep, tested with 100K characters and performing well. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/flodnv in version: 1.4.33-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.4.33-5 🚀
|
text: newComment, | ||
emojis, | ||
cursorPosition, | ||
} = EmojiUtils.replaceAndExtractEmojis(isEmojiInserted ? ComposerUtils.insertWhiteSpaceAtIndex(commentValue, endIndex) : commentValue, preferredSkinTone, preferredLocale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line caused a regression iOS - Chat - The cursor moves one space backward when inserting text after an emoji
Details
This PR fixes below regressions in #30412
Discussion here: #23658 (comment)
Fixed Issues
$ #23658
PROPOSAL:
Tests
:heart:
)Offline tests
:heart:
)QA Steps
:heart:
)PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android-web.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
iOS-mWeb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4