-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fixed Android - Chat - Message gets displayed from right to left #32297
Fixed Android - Chat - Message gets displayed from right to left #32297
Conversation
@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2023-12-04.at.12.35.43.AM.movAndroid: mWeb ChromeScreen.Recording.2023-12-04.at.12.34.17.AM.moviOS: NativeScreen.Recording.2023-12-04.at.12.32.33.AM.moviOS: mWeb SafariScreen.Recording.2023-12-04.at.12.32.00.AM.movMacOS: DesktopScreen.Recording.2023-12-04.at.12.30.32.AM.mov |
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!
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
c81a9fe
to
7c11e93
Compare
@samilabud @allroundexperts As I had worked on this for other platforms previously, I was getting some issues, and similar issues are visible in this change also:
23-12-05-16-38-32.mp4 |
Thanks for testing this out @HardikChoudhary24. In the screenshots I attached, I can see that the placeholder was appearing at-least 🤔. @samilabud Can you please check the issues that @HardikChoudhary24 pointed out? |
Good catch @HardikChoudhary24 thank you!. @allroundexperts currently this works better, please check it out: Testing.messages.gets.displayed.from.right.to.left.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.
I feel like the diff changed by an order of magnitude since the last time I looked at it and now I don't really follow the scope of the solution.
Are the problems mentioned by @HardikChoudhary24 caused by your PR, or are they existing bugs that are being fixed in this PR?
I think if they are regressions caused by your PR, they should be fixed in this PR. If they are existing bugs, then we should open up a new GH to track and fix them independently.
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
Hi, issues mentioned by @HardikChoudhary24 are caused by my PR but it looks like they tried this before and didn't works or something. I have fixed every scenario inside the corresponding files to make this change affect only android mobiles, also I have added comments that explain the why of this changes, please check them out 🙏🏼 |
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.
I know this is a lot of comments, but the changes in this PR really went down an interesting path!
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.js
Show resolved
Hide resolved
Thanks for the suggestions, I think I've addressed everything, please check back when you get a chance 🙏🏼 |
…naming variable from newCommentConverted to newCommentConvertedToLTR
Hi @tgolen, I think I finished with the changes please double-check because I marked the conversations as resolved and currently I see just 2 comments from you, could you please mark them as unsolved when you add a new comment? or maybe it is better to never mark comments as resolved 🤔. BTW when I was testing I found a new bug (this is not related to this PR, the test was in https://staging.new.expensify.com): Staging.Bug.in.Web.Chrome.mp4Do you know where we can report this? I think we can fix it too. |
For bugs not related to your PR, you can post them in the slack channel #expensify-bugs. For the comments, I would usually never manually mark things as resolved. I know there were some issues with my previous review and having multiple comments, so I will go through it this morning and clean it up and give another review. |
Got it, thank you! |
@allroundexperts do you want to give another testing pass on this to ensure it's still in working order before it's merged? There were quite a few changes since your initial testing I think. |
Sure thing @tgolen. I'll retest this tonight/tomorrow. |
I did some tests after the last change and everything seems to be ok: Testing.regex.variable.names.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.
It's looking better! I think we just need to clean up some of the grammar and comment formatting and then this is good.
* Sending an empty message; | ||
* Mention suggestions not works if @ or \s (at or space) is the first character; | ||
* Placeholder is not displayed if the unicode character is the only character remaining; | ||
* force: always remove the LTR unicode, going to be used when composer is consider as empty */ |
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.
The */
needs to go on the next line by itself.
* Sending an empty message; | ||
* Mention suggestions not works if @ or \s (at or space) is the first character; | ||
* Placeholder is not displayed if the unicode character is the only character remaining; | ||
* force: always remove the LTR unicode, going to be used when composer is consider as empty */ |
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.
If the force:
comment is for the force param, please format it as a legit @param
doc.
import ConvertToLTRForComposer from './types'; | ||
|
||
/** | ||
* Android only - The composer can be converted to LTR if its content is the LTR character followed by an @ or space |
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 comment should also explain why it's OK to convert it in these cases and why it shouldn't be converted. Consider adding "because..." and then fill out the rest.
* Android only - The composer can be converted to LTR if its content is the LTR character followed by an @ or space | ||
*/ | ||
function canComposerBeConvertedToLTR(text: string): boolean { | ||
// this handle cases when user type only spaces |
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.
Please start comments with a capital letter
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 handle cases" is not good grammar and should be more like "This regex handles the case when a user only types spaces into the composer.
function canComposerBeConvertedToLTR(text: string): boolean { | ||
// this handle cases when user type only spaces | ||
const containOnlySpaces = /^\s*$/; | ||
// this handle the case where someone has RTL enabled and they began typing an @mention for someone. |
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.
Do comments end with a period or not? Let's be consistent
const containOnlySpaces = /^\s*$/; | ||
// this handle the case where someone has RTL enabled and they began typing an @mention for someone. | ||
const startsWithLTRAndAt = new RegExp(`^${CONST.UNICODE.LTR}@$`); | ||
// this handle cases could send empty messages when composer is multiline |
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.
I'm not quite sure what this means and the grammar is a bit confusing. Are you trying to say this?
This regex handles the case where the composer can contain multiple lines of whitespace.
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.
That's right, sorry 😣!
Hi @tgolen, please verify again when you get a chance. |
* @newComment: the comment written by the user | ||
* @force: always remove the LTR unicode, going to be used when composer is consider as empty */ |
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.
These need to follow the JSDocs format: https://jsdoc.app/tags-param.
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.
The */
is still on the wrong 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.
Sorry, thanks for the link, I appreciate it (TIL).
Done.
All yours @allroundexperts |
@samilabud Now I am getting the following issue: Screen.Recording.2023-12-19.at.7.13.21.PM.mov |
Hi, do you mean the delay where text takes to be from left to right? If so, this seems to be the expect behavior due android has not transitions when we convert the input to LTR from RTL |
@samilabud I'm talking about the text suddenly moving from right to left. This did not happen in your previous versions. You can also confirm this by watching your / mine screen recordings for Android. |
Got it, I have noticed this behavior from beginning but it seems related to emulator/device available resources, this happen even in web version with a bug I reported previously in this thread. |
@allroundexperts I'm thinking maybe you mean the way it was it the beginning that we never allow the input to be converted to RTL but this causes mentions to not work, or blank messages to be sent, and so on. If this is a big issue please let me know so I can try to find another way to convert the input. |
What's the status with this? @allroundexperts I think you are suggesting that earlier commits in this PR didn't have the delay. Is that right? |
Yes, this has been happening since the first commits (see the video at sec 3 to this comment) but maybe you don't notice because this depends on the resources available: The reason is that we previously converted (in the proposal) the input before the user started typing (adding the Unicode), and now we have to wait for the user to type (to add the Unicode if has the conditions - to avoid sending an empty message, or mentions and placeholder works correctly). In summary, as we have to wait for the user to write it is noticeable when Android converts the input from RTL to LTR. |
I think that is OK to live with for now. Thank you for explaining! @allroundexperts are you OK for me to merge this then? |
@tgolen If that's fine, then I think we can merge this. |
Late Christmas present :D I wish I could have merged this yesterday 🎄 🎅 |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Thank you all, merry late Christmas! 🎄🎁 😊 |
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.18-8 🚀
|
Details
The root cause is that Android only converts RTL text to LTR text using Unicode controls and by default, when you start writing in a language that is written in RTL mode it converts the input text to RTL.
Fixed Issues
$ #30584
PROPOSAL: #30584 (comment)
Tests
Offline tests
N/A
QA Steps
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)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.Native.mov
Android: mWeb Chrome
Android.Chrome.mov
iOS: Native
Iphone.Native.mp4
iOS: mWeb Safari
Iphone.Safari.mov
MacOS: Chrome / Safari
Web.Chrome.mp4
MacOS: Desktop
MAC.Desktop.mov