Fix cursor not moving to the end of mention when using mention suggestions.#74886
Conversation
|
@thesahindia 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] |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb Chromemchrome.moviOS: HybridAppios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktop |
situchan
left a comment
There was a problem hiding this comment.
Looks good other than failing checks
situchan
left a comment
There was a problem hiding this comment.
Please add some context in Explanation of Change.
- Why debounce saveComment on
onClear - Why debounce updateComment on
onChangeText
|
@situchan I don't know the specific reason, we're just reverting to how it was months ago while maintaining some of the changes of my original PR. We should probably ask the person who used the debounces before all the regressions. I can try to investigate tomorrow if needed though. |
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good from a product perspective 👍
situchan
left a comment
There was a problem hiding this comment.
Please add explanation of new code changes. Looks like much different from initial proposal.
src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| InteractionManager.runAfterInteractions(() => { |
There was a problem hiding this comment.
Please move comment from old code.
There was a problem hiding this comment.
We need that comment so the ESLint doesn't trigger an error, it's used throughout the codebase as well, as far as I'm aware, we're currently not moving away from runAfterInteractions even though it's deprecated.
There was a problem hiding this comment.
I meant to keep
There was a problem hiding this comment.
And also keep this comment:
There was a problem hiding this comment.
I just added the old comments but changed some parts since the part about only being used on iOS is outdated (we're also imperatively setting the selection on Android).
|
@situchan The explanation is in the main issue comment:
But basically we're just imperatively setting the cursor position to the end of the current mention (e.g.: |
| (commentValue: string) => { | ||
| updateComment(commentValue, true); | ||
|
|
||
| if (isIOSNative && syncSelectionWithOnChangeTextRef.current) { |
There was a problem hiding this comment.
Did you test original bug - #29405 by removing iOS specific code?
It's still reproducible.
Screen.Recording.2025-11-16.at.12.18.52.PM.mov
There was a problem hiding this comment.
I completely missed that, sorry.
Updated the code to basically just implement the core fix of overwriting the cursor position when a suggestion is selected and keep the rest. Also updated the screen recordings for the tests showing that it works and that the bug you reported above^ is not reproducible anymore.
Just one question: Is it expected for the cursor to behave like your video in native Android? I found it currently moves to the end in all platforms except the Android app. And this happens even in main as shown below:
Screen.Recording.2025-11-16.at.8.11.28.AM.mov
There was a problem hiding this comment.
That can be out of scope as it's not caused by this PR
|
Had some problems with my GPG key, thus the failing check. I can rebase and force push with all the commits signed if this is a blocker. |
yes it's blocker. All commits should have verified signature. |
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| InteractionManager.runAfterInteractions(() => { |
There was a problem hiding this comment.
We're deprecating InteractionManager.runAfterInteractions. Please try to find another solution.
There was a problem hiding this comment.
I ended up using queueMicrotask because it seems to be the most appropriate since we're dealing with the cursor position which is lightweight and should probably happen before the next render.
eddded5 to
47eaca6
Compare
|
Whats the latest here @LorenzoBloedow, is it ready for review? |
|
Please merge main and fix failing perf-tests |
|
@situchan Merged |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb Chromemchrome.moviOS: HybridAppios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.mov |
chiragsalian
left a comment
There was a problem hiding this comment.
LGTM. Thank you for staying on top of this and pushing it through.
|
🚀 Deployed to staging by https://github.com/chiragsalian in version: 9.2.67-0 🚀
|
|
🚀 Deployed to staging by https://github.com/chiragsalian in version: 9.2.70-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.2.70-0 🚀
|
Explanation of Change
We're imperatively setting the cursor position to the end of the suggestion (when the user selects one) because we previously didn't have any logic for handling this so the cursor would just stay in the same position.
Fixed Issues
$ #61944
Tests
Test 1:
Test 2:
Test 3:
Test 4:
Offline tests
Same as tests.
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.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
Android.-.Native.mov
Android: mWeb Chrome
Android.-.Chrome.mov
iOS: Native
iOS.-.Native.mov
iOS: mWeb Safari
iOS.-.Safari.mov
MacOS: Chrome / Safari
macOS.-.Safari.mov
MacOS: Desktop
macOS.-.Desktop.mov