-
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
Resolve Cursor Position Issue on Long-Press in Android Chrome #30082
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -136,10 +136,19 @@ function MoneyRequestAmountForm({amount, currency, isEditing, forwardedRef, onCu | |||
if (!_.isEmpty(formError)) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
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.
@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 <[email protected]>
@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 |
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.
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 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
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