-
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
[CP Staging] input of '[' and other special characters fixed #30559
[CP Staging] input of '[' and other special characters fixed #30559
Conversation
@neil-marcellini @burczu Apologies for the inconvenience caused. In my last change, I used the
Please review my changes and let me know if any other use case needs to be tested. Thank you. |
// If text is empty string return empty string to avoid an empty draft due to special character. | ||
if (text === '' || CONST.UNICODE.LTR.match(text)) { | ||
if (text === '' || text.startsWith(CONST.UNICODE.LTR)) { | ||
return ''; | ||
} | ||
return text; |
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 text is empty string return empty string to avoid an empty draft due to special character. | |
if (text === '' || CONST.UNICODE.LTR.match(text)) { | |
if (text === '' || text.startsWith(CONST.UNICODE.LTR)) { | |
return ''; | |
} | |
return text; | |
return text.replace(CONST.UNICODE.LTR, ''); |
Anyway, when does this happen?
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.
What's the root cause of this bug? Why only [
not working but all other special characters work?
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 is because [
has a special meaning in regular expressions and CONST.UNICODE.LTR.match('[')
gives an error because [
is not properly escaped. If we do 'CONST.UNICODE.LTR.match(/\[/)
it will give null which we require but when we are passing a string we are just passing [
. This also happens for ?
, +
due to the same reason.
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.
Makes sense. Can you think of adding automated test cases? As you see, this might easily break composer input and affect bad user experience.
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.
Sure I will add automated test cases. Should I raise a new PR for that?
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 next deploy will be tomorrow (Monday) so if you can add them before that, that would be great.
Otherwise, we need to merge this before deploy to staging and work on unit test as a follow-up.
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 won't be able to complete the task before tomorrow as my current workload won't permit me to meet that deadline. Can we do it as a follow up?
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 am fine with it. cc: @neil-marcellini
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.
If requires reviewer checklist, I can do that. cc: @burczu
Going ahead checklist since it's now deploy blocker |
@HardikChoudhary24 while testing android, I noticed that مثال is displayed in RTL android.mov |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
Yes it will be in RTL for android as mentioned in comment also this can be seen for other apps like linkedin where the web version is having the desired result and there android app is not showing it in LTR format |
ok, we're good then. |
@aimane-chnaif I have added the test cases for this can you please review them once and please let me know if any other test case is required. |
Mix of LTR and RTL characters please. Also lint failing |
@@ -0,0 +1,71 @@ | |||
import convertToLTRForComposer from '@libs/convertToLTRForComposer'; | |||
import CONST from '@src/CONST'; | |||
import {platform} from 'os'; |
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.
Seems like new pattern. Not sure if it's the correct way to import platform in unit test
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.
Since we are having a android specific implementation for convertToLTRForComposer
where we are returning text without any modification is there any other way around to check for it in the test cases ?
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.
@aimane-chnaif I have fixed the lint issue it was due to the import of platform. Also I have removed the check for platform. I am not sure if it is correct or not let me know if something needs to be updated.
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.
Thanks for the quick fix and especially for the tests.
@neil-marcellini since we have different implementation of convertToLTRForComposer in android so is there a check for platform required in the test also? I am not sure about this thus I have not added any check for platform |
Is it possible to use platforms specific test files? It's not a big deal if we don't test Android, since it does nothing right? |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Yes even though it just returns the same text that is being passed but in the tests I have checked for specific cases like when we pass a RTL character we should get back a LTR marker concatenated at the start this might fail in case of android. However I ran the |
CPing fix to staging 👍 |
input of '[' and other special characters fixed (cherry picked from commit d651cab)
🚀 Cherry-picked to staging by https://github.com/Beamanator in version: 1.3.93-1 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.93-1 🚀
|
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 1.3.95-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.95-9 🚀
|
Details
This PR fixes the input of special characters as mentioned in #30521 comment.
Fixed Issues
$ #28149
$ #30578
PROPOSAL:
Tests
Offline tests
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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)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
MacOS: Chrome
chrome.mov
MacOS: Desktop
desktop.mov
Android: mWeb Chrome
WhatsApp.Video.2023-10-29.at.11.17.55.PM.mp4
iOS: Native
ios.mov
iOS: mWeb Safari
iosSafari.mov
MacOS: Safari
safari.mov
Android: Native
android.mp4