-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix mention suggestion highlight doesn't move when the text selection moves #39917
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
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.
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
@@ -227,7 +227,7 @@ function SuggestionEmoji( | |||
<EmojiSuggestions | |||
highlightedEmojiIndex={highlightedEmojiIndex} | |||
emojis={suggestionValues.suggestedEmojis} | |||
prefix={value.slice(suggestionValues.colonIndex + 1, selection.start)} | |||
prefix={value.slice(suggestionValues.colonIndex + 1, selection.end)} |
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.
(e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => { | ||
/** | ||
* we pass here e.nativeEvent.selection.end directly to calculateEmojiSuggestion | ||
* because in other case calculateEmojiSuggestion will have an old calculation value |
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.
Please update the comment.
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.
Updated
@@ -111,7 +111,8 @@ function Suggestions( | |||
|
|||
const onSelectionChange = useCallback((e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => { | |||
const emojiHandler = suggestionEmojiRef.current?.onSelectionChange?.(e); | |||
return emojiHandler; | |||
const mentionHandler = suggestionMentionRef.current?.onSelectionChange?.(e); | |||
return emojiHandler ?? mentionHandler; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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
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