[CP Staging] input of '[' and other special characters fixed#30559
[CP Staging] input of '[' and other special characters fixed#30559neil-marcellini merged 10 commits intoExpensify:mainfrom
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.
| // 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.
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.
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.
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.
Sure I will add automated test cases. Should I raise a new PR for that?
There was a problem hiding this comment.
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.
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.
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.
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.
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.
@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.
neil-marcellini
left a comment
There was a problem hiding this comment.
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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