Fix mention suggestion highlight doesn't move when the text selection moves#39917
Conversation
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
eh2077
left a comment
There was a problem hiding this comment.
Would you like to update the changes to focus on fixing suggestion highlight issue only please?
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Outdated
Show resolved
Hide resolved
| highlightedEmojiIndex={highlightedEmojiIndex} | ||
| emojis={suggestionValues.suggestedEmojis} | ||
| prefix={value.slice(suggestionValues.colonIndex + 1, selection.start)} | ||
| prefix={value.slice(suggestionValues.colonIndex + 1, selection.end)} |
| (e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => { | ||
| /** | ||
| * we pass here e.nativeEvent.selection.end directly to calculateEmojiSuggestion | ||
| * because in other case calculateEmojiSuggestion will have an old calculation value |
| const emojiHandler = suggestionEmojiRef.current?.onSelectionChange?.(e); | ||
| return emojiHandler; | ||
| const mentionHandler = suggestionMentionRef.current?.onSelectionChange?.(e); | ||
| return emojiHandler ?? mentionHandler; |
There was a problem hiding this comment.
I tried to test a corner case with precondition - have a user with Eric :smile: as the first name and empty second name.
By pasting text @eric :sm into composer, I got both two suggestion menus at the same time.


As prod has same issue and I'm not sure if this is expected, so I think we can also skip this one in this PR.
There was a problem hiding this comment.
Yeah, I always wondering whether both suggestions will show or not since we don't return anything inside onSelectionChange.
…t-mention-suggestion
|
Code looks good to me. I got stuck in building Android App. I'll update checklist once the Android build issue is resolved. |
|
@bernhardoj Typing android-mention-not-working.mov |
|
Thanks for catching that. The issue I found is that when App/src/pages/home/report/ReportActionCompose/Suggestions.tsx Lines 112 to 115 in d4bc1b0 So, I decided to remove Btw, you can reproduce it with emoji suggestions too if you remove this App/src/pages/home/report/ReportActionCompose/SuggestionEmoji.tsx Lines 181 to 186 in d4bc1b0 |
|
@bernhardoj There're conflicts need to be resolved. |
…t-mention-suggestion
|
Conflicts solved |
|
@bernhardoj I found another bug - suggestion menu is not closed after deleting Screen.Recording.2024-04-15.at.12.21.49.AM.mov |
|
@eh2077 I found that on Android mWeb, deleting a character won't immediately update the selection ( This doesn't happen on App/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx Lines 353 to 355 in db9e01c Do you think we should update the |
|
@bernhardoj Hmm, I think the new issue introduced - suggestion menu is not closed after deleting |
|
Agree, I have updated the |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemobile-chrome.moviOS: Nativeios.moviOS: mWeb Safarimobile-safari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
eh2077
left a comment
There was a problem hiding this comment.
Code looks good and tested well!
|
✋ 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/stitesExpensify in version: 1.4.63-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.63-21 🚀
|


Details
The highlight of the mention is based on the
prefix. The current prefix doesn't consider the selection position of the input. This PR changes it so it's consistent with emoji suggestion too.Fixed Issues
$ #39102
PROPOSAL: #39102 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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
Screen.Recording.2024-04-09.at.19.00.21.mov
Android: mWeb Chrome
Screen.Recording.2024-04-09.at.19.10.58.mov
iOS: Native
Screen.Recording.2024-04-09.at.18.58.22.mov
iOS: mWeb Safari
Screen.Recording.2024-04-09.at.18.59.59.mov
MacOS: Chrome / Safari
Screen.Recording.2024-04-09.at.18.25.38.mov
MacOS: Desktop
Screen.Recording.2024-04-09.at.18.57.42.mov