-
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
[Awaiting Payment 13th June] [$4000] Android - Edit message - keyboard is dismissed after selecting an emoji #29011
Comments
Current assignee @trjExpensify is eligible for the Bug assigner, not assigning anyone new. |
Job added to Upwork: https://www.upwork.com/jobs/~016af206b246b07b5a |
Bug0 Triage Checklist (Main S/O)
|
Current assignee @parasharrajat is eligible for the External assigner, not assigning anyone new. |
ProposalPlease re-state the problem that we are trying to solve in this issue.After selecting an emoji the keyboard is not visible What is the root cause of that problem?App/src/components/EmojiPicker/EmojiPicker.js Lines 67 to 78 in 98f3b43
What changes do you think we should make in order to solve the problem?the function above should change focus on the input to show the keyboard after the emoji is selected: |
ProposalPlease re-state the problem that we are trying to solve in this issueEdit message - keyboard is dismissed after selecting an emoji What is the root cause of that problem?The first click will hide the emoji picker but can not open the Keyboard again App/src/components/EmojiPicker/EmojiPicker.js Lines 96 to 107 in 98f3b43
What changes do you think we should make in order to solve the problem?We should open the keyboard again just after selection the emoji. We already have such code in other onModalHide prop is called as soon as EmojiModal close & focus the keyboard but it is already focussed hence following code will open the Keyboard.
What alternative solutions did you explore? (Optional)NA |
ProposalPlease re-state the problem that we are trying to solve in this issue.Android - Edit message - keyboard is dismissed after selecting an emoji What is the root cause of that problem?Calling focus when input is already focused, not trigger opening keyboard on android. 20231006200406138.mp4the composer is focused while we type the emoji, so when modal hide and calling focus() while is already focused, it not trigger opening keyboard on android. What changes do you think we should make in order to solve the problem?If Input is already focused, call blur then focus
we can do this for android only, and can focus any other view then focus input here App/src/libs/focusWithDelay.ts Line 8 in 0ce103d
As I see other proposal after my proposal just try to change the place where call blur(), I think we can discuss that in the PR What alternative solutions did you explore? (Optional)we can open keyboard programmatically by create native module to open keyboard, and use it like if input focus show keyboard else focus. |
ProposalPlease re-state the problem that we are trying to solve in this issue.When the main composer is in focused state, the main composer gets focused after clicking emoji button and selecting emoji, but keyboard isn't opened What is the root cause of that problem?When clicking the emoji button, the composer doesn't get blurred. You can verify this by checking whether This is the root cause What changes do you think we should make in order to solve the problem?In order for calling focus() to open the keyboard, we need to blur the text input when emoji button clicked.
We can do this in ReportActionItemMessageEdit as well This works as expected Result29011_android_native.mp4What alternative solutions did you explore? (Optional) |
ProposalPlease re-state the problem that we are trying to solve in this issue.Keyboard not showing up on edit text message after selecting an emoji What is the root cause of that problem?When the EmojiPicker panel is being hidden we call the following. onModalHide={() => {
setIsFocused(true);
focus(true);
}} This looks fine except that the text input is already focused and calling the focus again will not trigger the keyboard. What changes do you think we should make in order to solve the problem?We can take advantage of We then need to add new prop to the <EmojiPickerButton
isDisabled={props.shouldDisableEmojiPicker}
onModalHide={() => {
setIsFocused(true);
focus(true);
}}
onWillShow={() => {
if(!textInputRef.current.isFocused()) {
return
}
textInputRef.current.blur();
}}
onEmojiSelected={addEmojiToTextBox}
nativeID={emojiButtonID}
emojiPickerID={props.action.reportActionID}
/> Monosnap.screencast.2023-10-06.22-16-46.mp4What alternative solutions did you explore? (Optional)N/A |
ProposalPlease re-state the problem that we are trying to solve in this issueKeyboard doesn't open up after selecting emoji on both report composer and report edit composer. What is the root cause of that problem?The root cause of the problem happens only on Android and seems to be caused by the closing animation of the emoji picker popover: App/src/components/EmojiPicker/EmojiPicker.js Lines 141 to 146 in 389d7b0
App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 390 to 395 in 389d7b0
My assumption is that because this popover animation cannot be disabled and the 1ms animation time in / out was set this affects the focus called from What changes do you think we should make in order to solve the problem?After getting some context by reading 300+ comments in the original issue and diving into the code this is what I came up with. App/src/components/EmojiPicker/EmojiPicker.js Lines 96 to 107 in 389d7b0
Within the const selectEmoji = (emoji, emojiObject) => {
// Prevent fast click / multiple emoji selection;
// The first click will hide the emoji picker by calling the hideEmojiPicker() function
if (!isEmojiPickerVisible) {
return;
}
// dismisses the keyboard before the popover close animation is finished (setState below)
// without this Android keyboard won't show up on input focus until the user taps on the input
+ if (Platform.OS === 'android' && !Keyboard.isVisible()) {
+ Keyboard.dismiss();
+ }
hideEmojiPicker(false);
if (_.isFunction(onEmojiSelected.current)) {
onEmojiSelected.current(emoji, emojiObject);
} this makes sure the keyboard is dismissed before the popover is closed. When the popover is closed and the composer focus is called from the Result:Android - Real devicereal-alt.mp4Android - Emulatoremulator-alt.movWhat alternative solutions did you explore? (Optional)The OP mentions that we don't want any jumpy freezing transition between the popover closing and the keyboard showing up which happens due to this part of the code: App/src/pages/home/report/ReportFooter.js Line 82 in 389d7b0
because when the edit composer is focused the To diminish that jumpy freeze I came up with the following additions to the // -> above the component declaration, under imports
// enables LayoutAnimation for Android
+ if (Platform.OS === 'android') {
+ if (UIManager.setLayoutAnimationEnabledExperimental) {
+ UIManager.setLayoutAnimationEnabledExperimental(true);
+ }
+ }
// -> before component return
+ const previousShouldShowComposeInput = usePrevious(props.shouldShowComposeInput);
// android only, applies transition when the ReportActionCompose is being hidden
+ if (Platform.OS === 'android' && previousShouldShowComposeInput && !props.shouldShowComposeInput) {
+ LayoutAnimation.configureNext({
+ duration: CONST.LAYOUT_ANIMATED_TRANSITION, // <- 400ms added to CONST
+ update: {type: LayoutAnimation.Types.easeOut, property: LayoutAnimation.Properties.opacity},
+ });
// android only, resets LayoutAnimation by setting transition duration to 1ms when the ReportActionCompose is being shown
+ } else if (Platform.OS === 'android') {
+ LayoutAnimation.configureNext({
+ duration: 1,
+ update: {type: LayoutAnimation.Types.easeOut, property: LayoutAnimation.Properties.opacity},
+ });
+ } For sure the duration is adjustable because 400ms might be too slow, this is just an example as to how LayoutAnimation can be used to smooth things out or at least give that sensation. Alternative result:Android - Real devicereal.mp4Android - Emulatoremulator.mov |
ProposalPlease re-state the problem that we are trying to solve in this issue.Android - Edit message - keyboard is dismissed after selecting an emoji What is the root cause of that problem?We have a couple of issues here causing the problem: First issue is with these two codes working together: App/src/pages/home/report/ReportActionItemMessageEdit.js Lines 392 to 394 in fabff79
App/src/pages/home/report/ReportActionItem.js Lines 182 to 188 in fabff79
The issue here is that on message edit we are focusing on the TextInput through ReportActionItem's useEffect and there is nothing blurring that focus and so when onModalHide tries to focus the TextInput since it's already focused this causes Android by it's default behaviour to not show the keyboard since the focus status of the TextInput hasn't changed. The second issue is with this code:
The problem here is that platforms handle operations differently, on Android when changing the current refs or re-rendering components, the ref doesn't get assigned correctly on the first render and so since we are instantly calling focusWithDelay with no regards to textInputRef.current, it will always recieve a null value for textInputRef.current so it will exit early in this part of it's code: App/src/libs/focusWithDelay.ts Lines 17 to 19 in fabff79
What changes do you think we should make in order to solve the problem?First of all we need to resolve the focus conflict, we can do that by simply blurring the TextInput when the EmojiPickerButton is pressed: <EmojiPickerButton
isDisabled={props.shouldDisableEmojiPicker}
onPress={() => {
textInputRef.current.blur();
}} Next we need to resolve the null ref issue, we can do that by using useCallback to call focusWithDelay insuring it doesn't recieve a null and so having a more robust way of passing the ref: const focus = useCallback(() => {
const focusFunction = focusWithDelay(textInputRef.current)
focusFunction(true);
}) ResultWhatsApp.Video.2023-10-09.at.3.20.56.AM.mp4 |
Thanks for all proposals. I will review this today. |
ProposalPlease re-state the problem that we are trying to solve in this issue.Android - Edit message - keyboard is dismissed after selecting an emoji What is the root cause of that problem?when user open the emoji picker we are not giving focus to the EmojiPickerMenu View therefore input is not blurred What changes do you think we should make in order to solve the problem?we can simply give the focus to the EmojiPickerMenu view using useRef to solve this issue add ref to the root view of the EmojiPickerMenu index.native.js
focus the EmojiPickerMenu when user open the modal using useEffect
Result Screen.Recording.2023-10-09.at.11.40.07.mov |
📣 @chira37! 📣
|
@parasharrajat I'm not sure if it is reproducible anymore. This PR could fix this |
In my proposal, I mentioned the known issue of The point of the issue is that calling |
@Julesssss, @trjExpensify, @parasharrajat Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
Reviewing... |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
What's the latest here? |
There is a chain of dependencies here that starts with the new architecture changes. So the issue we are currently holding on requires updates to the 2nd PR. |
Wowza! Jules, you have an Android device to corroborate that? Exciting! |
Confirmed fixed 🎉 It's payday 🤑 |
I'm currently switching to newdot for payments, would appreciate it if you can temporarily hold the payment. 😄 |
Haha, certainly. Let me know here when you're done. :) |
Hi, @trjExpensify, I have switched to ND and smoothly received payments for the other two issues. 😄 |
$4,000 approved for @ntdiary |
Bumped in Slack |
@trjExpensify accepted the offer |
Great, I think this can be closed. |
I need to pay it. |
Paid! |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action steps:
Edit message
Expected results:
The alphabetical keyboard should not be dismissed after selecting an emoji
Note: For the iOS Safari platform, it only focuses without opening the keyboard, which is another separate issue and is beyond the scope.
Note: No hacks, we need a proper solution to solve this issue. The speed of the keyboard showing back matters. There should be no delay before the keyboard is shown back and after the picker is closed. it should feel spontaneous.
There's extensive history on the original issue here. Please ask for any clarifying questions!
Actual Result:
Keyboard doesn't open up after selecting emoji.
Workaround:
Unknown
Platform:
Where is this issue occurring?
Version Number: v1.3.78-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
Email or phone of affected tester (no customers): any
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Screen_Recording_20220415-030417_New.Expensify.mp4
Issue reported by: @Tushu17
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1650039236885699
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: