Resolve Cursor Position Issue on Long-Press in Android Chrome#30082
Conversation
|
@abdulrahuman5196 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] |
| setSelection((prevSelection) => getNewSelection(prevSelection, isForwardDelete ? strippedAmount.length : prevAmount.length, strippedAmount.length)); | ||
| if (!hasSelectionBeenSet) { | ||
| setSelection((prevSelection) => { | ||
| hasSelectionBeenSet = true; |
There was a problem hiding this comment.
any reason to set it inside the setSelection, wouldn't having it after the if statement more meaningful?
There was a problem hiding this comment.
Yes that makes more sense. That's what I had intially tried but saw some issues. I don't see those now, so i have moved the hasSelectionBeenSet out of setSelection
| setFormError(''); | ||
| } | ||
|
|
||
| // There was an issue where long-pressing the back button in Android Chrome removed the last digit but moved the cursor ahead two positions instead of one. This occurred because setCurrentAmount contains another setState, making it impure and error-prone. Various solutions were suggested, including merging currentAmount and selection; however, this solution introducing the hasSelectionBeenSet flag was chosen for its simplicity and lower risk of future errors https://github.com/Expensify/App/issues/23300. |
There was a problem hiding this comment.
This is super long. Can we make it short and crisp and link the GH comment..
|
@ygshbht Kindly check on these minor comments and kindly do add details of PR in the PR details section |
|
@abdulrahuman5196 Done |
|
@abdulrahuman5196 Let's try to get this closed within 3 days! |
abdulrahuman5196
left a comment
There was a problem hiding this comment.
@ygshbht Kindly update this
|
Reviewing now |
|
@ygshbht I am seeing this issue where if i place the cursor in between the digits and press back button it still deletes the last digit. Same goes for long press as well. The same is not happening in staging. az_recorder_20231023_161907.mp4 |
Co-authored-by: abdulrahuman5196 <46707890+abdulrahuman5196@users.noreply.github.com>
|
@abdulrahuman5196 Isn't this the same issue that koko #23300 (comment) mentioned and you too previously? Apart from this issue (where you long press back button and then the curson position is not updated), I don't see any other issue. It's there is staging too. Can you please check if you are testing with the latest code and retest in staging? |
Yes. I did test with the latest code in this PR and with staging. Staging the issue is not occuring and in this PR the issue is occuring. @ygshbht Could you check again and provide videos if you are able to repro that issue in staging? |
|
@abdulrahuman5196 Staging video XRecorder_23102023_181107.mp4 |
|
Got it. This issue seems to be present in staging as well. |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-10-24.at.3.38.17.PM.mp4Mobile Web - Chromeaz_recorder_20231024_154156.mp4Mobile Web - SafariScreen.Recording.2023-10-24.at.3.48.10.PM.mp4DesktopScreen.Recording.2023-10-24.at.4.02.44.PM.mp4iOSScreen.Recording.2023-10-24.at.3.52.19.PM.mp4AndroidScreen.Recording.2023-10-24.at.3.58.47.PM.mp4 |
abdulrahuman5196
left a comment
There was a problem hiding this comment.
Changes looks good and works well. Reviewers checklist is also complete.
All yours. @madmax330
🎀 👀 🎀
C+ Reviewed
|
Gentle ping @madmax330 |
|
✋ 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/madmax330 in version: 1.3.91-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 1.3.91-8 🚀
|
Details
This PR aims to solve an issue where long-pressing the back button in Android Chrome removes the last digit but moves the cursor ahead two positions instead of one. This occurrs because setCurrentAmount contains another setState, making it impure and error-prone. Various solutions were suggested, including merging currentAmount and selection; however, this solution introducing the hasSelectionBeenSet flag was chosen for its simplicity and lower risk of future errors #23300 (comment).
Fixed Issues
$ #23300
PROPOSAL: #23300 (comment)
Tests
Offline tests
Same as tests
QA Steps
Same as tests
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
Android: Native
XRecorder_20102023_193451.mp4
Android: mWeb Chrome
XRecorder_20102023_185626.mp4
iOS: Native
2023-10-20.19-41-18.mp4
iOS: mWeb Safari
2023-10-20.19-37-52.mp4
MacOS: Chrome / Safari
2023-10-20.19-07-29.mp4
MacOS: Desktop
2023-10-20.19-44-51.mp4