-
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 keyboard issues in add attachment flow #15337
Fix keyboard issues in add attachment flow #15337
Conversation
@joelbettner @thesahindia One of you needs to 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] |
@@ -613,8 +626,10 @@ class ReportActionCompose extends React.Component { | |||
icon: Expensicons.Paperclip, | |||
text: this.props.translate('reportActionCompose.addAttachment'), | |||
onSelected: () => { |
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.
@priyeshshah11 we need to add the this.focus(true);
inside onClose
of PopoverMenu
as well, otherwise if the user clicks +
and then click outside, it will not focus the input
…issing native picker once & DRY refactor
@tienifr @thesahindia @joelbettner All videos have been uploaded & PR is ready for review |
Reviewing in a few hours. |
Noting here - We have an edge case bug where we won't get the focus back on mWeb iOS if the user cancels the native file picker as there is no way to detect that in mWeb iOS because the focus never goes away from the screen nor there is any event listener for that https://stackoverflow.com/questions/74861458/how-to-tell-if-user-cancels-html-file-input-on-ios |
Hey @priyeshshah11, it looks like the keyboard isn't opening in android when I open actions menu and close it. It works on emulator but not on a real device. |
Ohh, unfortunately I don't have an android device to debug. @tienifr do you happen to have an android device? I'll still try to figure out by looking at the code, it could be the |
@thesahindia Meanwhile for quick testing, could I please request you to test it with commenting this line? Normally I wouldn't ask, sorry 😢 |
Still no luck Screenrecording_20230223_222212.mp4 |
Passing in true here should fix it, testing on other platforms. |
It's still the same. |
Thanks for trying that @thesahindia and yes you're right that wouldn't have made any difference on native as that condition is always false on native and it looks like we are actually doing that on purpose to avoid some jarring UI when keyboard opens on native |
@thesahindia @priyeshshah11 I don't encounter the Android keyboard not opening issue mentioned above, on my physical Android device Screenrecorder-2023-02-24-13-17-55-409.mp4 |
@tienifr can you please try in a new chat/empty room like @thesahindia's video? |
But I suspect the issue on your device might be due to the timeout set here
It might be too low for some scenarios and it's been increased before (like in here) to make sure the timeout is enough. @thesahindia can you try increasing that timeout value to see if the issue still persists? |
@priyeshshah11 I tried again just now on a physical device on the same announce chat which is empty, could not see the issue either. Screenrecorder-2023-02-24-13-44-29-1.mp4 |
Thanks @tienifr, Your comment above makes sense & looks like a potential cause. |
I tested this on two physical android devices. I had to increase the delay to 250 for one device and 400 for the other and I was still able to repro the issue after 2-3 tries (at chats with long message history). With emoji picker modal I didn't experience any problem, so I think we should check why the same issue can't be reproduced when we close emoji picker modal. |
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<Popover | ||
onClose={this.close} | ||
onClose={() => { |
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.
@priyeshshah11 We're using onClose
here to trigger the focus which will face the same issue on Android where it fails to open the keyboard. We might want to use use onModalHide
here instead.
…keyboard-flash-on-add-attachment
…nto fix-keyboard-flash-on-add-attachment" This reverts commit f00881b.
Build in progress |
Keyboard doesn't reopen on Pixel 6. screen-20230428-234356_2.mp4 |
Ok so my conclusion is that this is an issue with the react native modal lib where it calls the We have seen this same issue multiple times before in our repo itself, again without any permanent solution. However, @s77rt has this PR open for almost 4 months now without any activity from the maintainers or on the repo itself since almost a year now. I believe we have 2 options to move forward:
|
@rushatgabhane, thanks for the testing! |
Thanks for the links! I will check this in few hours. After completing other pending tasks |
Hi, this PR react-native-modal/react-native-modal#733 is mostly for Web. I don't know if it will fix the bug on Native too. |
any particular reason why it might not if it's kind of the same issue? the solution doesn't really seem platform specific. I do understand that they all behave differently under the hood but just asking if there are any obvious reasons. |
@priyeshshah11 The solution was based on another root cause which is the focus trap that is enforced by |
@tienifr @priyeshshah11 can you guys check if the fix will solve our problem? |
I don't think we will be able to as neither of us can reproduce that bug but I feel it will fix it for native if it fixes for web but I can't say for sure. |
How are things going here @priyeshshah11 @thesahindia @tienifr?
Do we have a solution that we know works for most platforms, but are just unable to test/reproduce it on certain platforms? If that is the case, I think we should go with what we have if we know it fixes it for some platforms. Your thoughts @trjExpensify , @Julesssss? |
@joelbettner The current code of this PR fixes the main bug but causes a minor regression on some android devices where it doesn't open the keyboard after dismissing a modal (it does focus the TextInput but just doesn't open the keyboard). I do have a fix for this, which is to use a I know no one likes Also, I would really like to understand exactly what's wrong in using |
Our approach is to address the problem at its core, which is why we refrain from using I was looking into #9252, it's a similar issue (not the same though), and looks like it will be fixed by #11684. So, I think we should wait for #11684 and test this again. |
I understand that & I have already given more than sufficient explanation for the cause & the fix several times above & in the issue. @joelbettner let me know if the explanation above makes sense?
well, we have been waiting for far too long on this issue expecting other things to fix it or to try & find the perfect solution even when we have a 99% working solution & we are holding this PR for a seperate known bug that has appeared in several other parts of the app as linked above. I don't think that's fair from a contributor's POV as we don't have unlimited time to be spent on each issue, this should also been taken into consideration. cc: @trjExpensify |
Hey @priyeshshah11, apologies but I think we dropped this one. QA tested the build again yesterday but it looks like the PR is out of date. If you can resolve the conflicts I'll generate a new build for QA to verify and we can hopefully get this merged. |
🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪 |
I'm going to close this for now. We can re-open in the future if needed. |
Details
A. For iOS: When opening the PopoverMenu, the keyboard will be closed (but the state of the keyboard opening is remembered by the OS). Then clicking Add attachment, the PopoverMenu is closed but the OS will reopen the keyboard. So when the AttachmentPicker is opened, due to this the keyboard is immediately closed, causing the glitch. We should only open the Modal component after the keyboard is completely hidden and when the AttachmentPicker, AttachmentModal, and PopoverMenu is closed/hidden, the keyboard will be reopened as expected.
B. For mWeb: When opening the PopoverMenu and then clicking Add attachment, the PopoverMenu will be closed. But the input is then focused and the keyboard is pushed up. After that, the native file picker appears and dismisses the keyboard immediately, causing the flickering. We should add a new state to indicate that we're opening the attachment picker and we do not refocus the input here if this state is true.
This PR does those
Fixed Issues
$ #13922
PROPOSAL: #13922 (comment)
Tests
Note: Keyboard won't open back on mWeb iOS which is known issue & out of scope of this PR
Offline tests
Same as above
QA Steps
Same as Tests above
Additional step: Verify the keyboard is focused back on cancelling/exiting out of the add attachment flow at every/any step except for mWeb iOS.
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)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
Web
web.mp4
Mobile Web - Chrome
mWeb.Chrome.mov
Mobile Web - Safari
Mweb.-.Safari.mp4
Desktop
desktop.mp4
iOS
ios.mp4
Android
Android.mov