-
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
feat: add whitespace after inserting emoji via native keyboard #30412
Conversation
Reviewer Checklist
Screenshots/VideosAndroid: Native30412.Android.mp4Android: mWeb Chrome30412.mWeb-Chrome.mp4iOS: Native30412.iOS.mp4iOS: mWeb Safari30412.mWeb-Safari.mp4MacOS: Chrome / Safari30412.Web.mp4MacOS: Desktop30412.Desktop.mp4 |
@aswin-s Could you help resolve the conflict? Thanks! |
@mollfpr Something has changed on master and I can see some issues related to emoji suggestions. Emoji suggestions popup is not shown when there is no text in the composer. It seems to be impacting master as well. Need more time to investigate and fix. I'll update you once it is resolved. |
@mollfpr Resolved conflicts and merged latest master which fixed the above mentioned issues. You may proceed with review. |
start: prevSelection.start + text.length + selectionSpaceLength, | ||
end: prevSelection.start + text.length + selectionSpaceLength, | ||
})); | ||
(text) => { |
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.
We need to update these line
replaceSelectionWithText(e.key, false); |
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.
Fixed. Removed the second parameter which is redundant now.
setSelection((prevSelection) => ({ | ||
start: prevSelection.start + text.length + selectionSpaceLength, | ||
end: prevSelection.start + text.length + selectionSpaceLength, | ||
})); |
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 think this removed code makes a regression.
Screen.Recording.2023-10-30.at.20.43.23.mov
Step to reproduce:
- Type a text
- Place the cursor in the middle
- Unfocus the composer
- Press any alphabet key
The cursor should stay in the last position before the unfocus.
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.
Nice catch 🙌. I had inadvertently removed the code to reset cursor position when the composer was focused again. However the method replaceSelectionWithText
doesn't seem like an apt location for it as the method is shared with EmojiPicker callback. Instead I moved the code to the focus handler method itself which will reset the cursor to its last known location.
@mollfpr Fixed the issue related to composer focus. You may retest the fix now. |
// Reset cursor to last known location | ||
setSelection((prevSelection) => ({ | ||
start: prevSelection.start + 1, | ||
end: prevSelection.end + 1, |
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'm a bit confused about this logic. Previously, we also sum the text length, but not here.
@aswin-s Could you explain more?
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.
@mollfpr Earlier it had to handle both Emoji picker input and Keyboard onPress. When emoji was inserted via picker selection, it had to adjust for emoji with white space. Now since the logic is moved into key press event, the selection is always going to be incremented by one, since it gets triggered only once for the first character being inserted.
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.
It looks good and tests well 👍
Just a minor JSDoc left.
* Find diff between text changes in composer | ||
*/ | ||
const findNewlyAddedChars = useCallback( | ||
(prevText, newText) => { |
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.
Missing the params JSDoc.
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.
Added JSDoc params
✋ 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/flodnv in version: 1.3.96-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.96-15 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.97-7 🚀
|
Details
This PR adds the functionality of adding a whitespace after an emoji is inserted via native keyboard. Earlier this behaviour was present only if emoji is inserted via in app Emoji picker.
Fixed Issues
$ #23658
PROPOSAL: #23658 (comment)
Tests
:heart:
)Offline tests
:heart:
)QA Steps
:heart:
)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
android.mp4
Android: mWeb Chrome
android-web.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
iOS-mWeb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4