-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[No QA] fixed keyboard appears on split bill page #2022
[No QA] fixed keyboard appears on split bill page #2022
Conversation
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.
Looking good., but is there a reason you didn't end up going with this solution?
My understanding was that it would replace the need for us to handle the focus/blur lifecycle. But please correct me if I'm wrong here.
@Julesssss. It was not working. |
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.
had one small comment, looks good otherwise
…asharrajat/keyboard-fix
@nickmurray47 @Julesssss Updated. |
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.
LGTM - will leave final review / merging up to @Julesssss
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.
Looks good to me, but I'm going to ask for one more reviewer.
Requested a review from someone more experienced with React Native |
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.
Not blocking this PR. But I'm concerned this pattern will add complexity we don't need and overall feels like there might be a better way to solve this issue.
There are really only a handful of cases where we will want to focus the report comment input. Rather than add another check to see if we are focused on the report page it would be good to try to come up with some solution to explicitly focus the input based on actions the user is taking e.g. navigating to a report, closing the attachment modal etc.
I think if we can figure out how to do this... then there'd be no need to track screen focus or whether modals have "just been hidden" etc.
@marcaaron Exactly. I was thinking that keyboard focus has many issues and this solution is limited to a small scope. We should only focus on special cases. Let me see into this. Few issues :
It would be helpful if I can get a list of actions when we have to explicitly set the focus. |
@Julesssss @nickmurray47 Thanks for the review. But I think we can keep this on hold.
I would like to mold the PR in this direction. |
I think the cases are:
|
waiting for new implementation
Hey guys, can we get a quick update on where we're at with this please? |
@trjExpensify. I am looking at other options to manage the focus on the Composer. There is a lot of discussion going around this issue. There are some issues #2100, #2154 which could change the behavior of the composer so I was waiting to have some update on that. I also saw that It was suggested that we should not focus on the Composer at all when we open the report from LHN. |
@marcaaron Updated. Let me know your thoughts. And keyboard dismiss issue is gone after adding loader for report screen. |
@marcaaron I have pushed the new changes and there are a few lint errors which I will resolve after your review. |
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.
Working well but have a few clean up requests. Thanks!
this.textInput.focus(); | ||
InteractionManager.runAfterInteractions(() => { | ||
this.textInput.focus(); | ||
}); |
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 confused about what issue this is addressing. Can we add some comments to explain what interactions we are waiting to finish?
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.
Animations do not run smoothly, as a side effect of the focus. So this case should suffice when the modal closes. It's a precautionary check that's all. Not particularly needed for these changes.
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.
Cool whatever it is, please add an explanation so we have some insights when looking at the code. Out of curiositym is there a particular modal closing that causes jank? Maybe we can add a test to verify it does not look janky?
cc @Julesssss We should also maybe update these test steps so that it is testable by QA?
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.
So, the Most effect of focus interfering with animation can be seen on a new chat or new group screen where we set the focus on Search input. Here, we may need this on the web when we close modals and then set focus back to Input but it's not apparent. Due to the similar effect happening on New Chat modals, I thought it's better to apply Interactionmanager
on all the places where we are setting focus.
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.
So, the Most effect of focus interfering with animation can be seen on a new chat or new group screen where we set the focus on Search input.
But these are due to the autoFocus
. The logic here would be applied for manual/programmatic focuses only
If you want to make auto focus wait for interactions as well you'll need to remove the autoFocus
prop and call this.focus()
when the component mount
I thought it's better to apply
Interactionmanager
on all the places where we are setting focus.
This applies it only here on compose though right? Opening a new chat or search use the TextInputFocusable
Instead of adding this logic to all the places that set focus couldn't it perhaps be added to TextInputFocusable
.
TextInputFocusable
can wrap inputRef.focus
with this behavior (before exposing it to parents)
Since focusing is done inside a callback, is it guaranteed you will always be inside a chat when this callback is invoked? Could it be possible for the user to tap/swipe too fast, open a chat and go back to LHN or somewhere else and then this callback runs and focuses the field?
if (this.textInput)
-textInput
- could be defined before setting this interaction, but could have changed inside the actual callback- you will want to abort this interaction in case the component is unmounted but the callback is still scheduled to run. Similar to how you would clean up timers when a component unmounts
focus() {
this.scheduledIntercation = Interactionmanager.runAfterInteractions(() => {...})
}
componentWillUnmount() {
if(this.scheduledIntercation) this.scheduledIntercation.cancel()
}
I think this works great, just that it should have been reusable/configurable for the other input fields as well
Not seeing how this can be done. |
…asharrajat/keyboard-fix
@marcaaron Updated the QA steps. |
Code Updated. Thanks. |
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.
Looks great thanks!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
this.textInput.focus(); | ||
InteractionManager.runAfterInteractions(() => { | ||
this.textInput.focus(); | ||
}); |
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.
So, the Most effect of focus interfering with animation can be seen on a new chat or new group screen where we set the focus on Search input.
But these are due to the autoFocus
. The logic here would be applied for manual/programmatic focuses only
If you want to make auto focus wait for interactions as well you'll need to remove the autoFocus
prop and call this.focus()
when the component mount
I thought it's better to apply
Interactionmanager
on all the places where we are setting focus.
This applies it only here on compose though right? Opening a new chat or search use the TextInputFocusable
Instead of adding this logic to all the places that set focus couldn't it perhaps be added to TextInputFocusable
.
TextInputFocusable
can wrap inputRef.focus
with this behavior (before exposing it to parents)
Since focusing is done inside a callback, is it guaranteed you will always be inside a chat when this callback is invoked? Could it be possible for the user to tap/swipe too fast, open a chat and go back to LHN or somewhere else and then this callback runs and focuses the field?
if (this.textInput)
-textInput
- could be defined before setting this interaction, but could have changed inside the actual callback- you will want to abort this interaction in case the component is unmounted but the callback is still scheduled to run. Similar to how you would clean up timers when a component unmounts
focus() {
this.scheduledIntercation = Interactionmanager.runAfterInteractions(() => {...})
}
componentWillUnmount() {
if(this.scheduledIntercation) this.scheduledIntercation.cancel()
}
I think this works great, just that it should have been reusable/configurable for the other input fields as well
// open creates a jarring and broken UX. | ||
if (this.shouldFocusInputOnScreenFocus && this.props.isFocused | ||
&& prevProps.modal.isVisible && !this.props.modal.isVisible) { | ||
this.setIsFocused(true); |
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.
setIsFocused(true)
would be called when the field is focused anyway.
Though if there is a legit reason to call it here, the call can just be moved inside the focus
method
this.setIsFocused(true);
this.focus();
vs
this.focus();
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 thoughts. Yeah Cancellation of Interaction is good to have.
But about autofocus, I think there are some PR on react native that are handling animation and focus issue. But I agree lets just move the interaction based focus to TextInputFocusable. I didn't do this here as that covers bigger scope then the current issue. So its better to first analyze the effect of these changes and consider them.
@marcaaron @Julesssss @nickmurray47 I don't think we're able to QA this PR since it requires changing some code. Can you guys assign someone to QA and let me know once it's done so we can check it off the list? Thanks in advance. |
Just tested this and noticed that while the Keyboard doesn't display when opening a Modal, adding an attachment seems to have broke (iOS only, Android works fine) (if this is a regression from another issue please correct me).
RPReplay_Final1618482151.MP4 |
@Julesssss as per the changes here, we have removed automatic opening of keyboard on Native devices. So autofocus should not happen at all. I think this is regression from another PR |
@Julesssss @parasharrajat Due to the modal handling at the time (autofocusing) it was necessary to add this. Otherwise the 2nd modal would disappear immediately The decision to drop autofocus happened a week or more later. |
Previously with the autofocus behavior something similar would happen (again only on iOS) When the input is not focused
|
I see. I will patch in another PR for that but its not a regression of this one so no need to reopen this. |
@parasharrajat @Julesssss The fix above resolves the issue - see the first part of the video below Removing the focus lineScreen.Recording.2021-04-15.at.14.35.47.movThis is why I originally had a Replacing with blurScreen.Recording.2021-04-15.at.14.49.04.movReplacing with blur seem to work better. As far as I tested back then it didn't cause any issues on the other mobile platforms If you want to I can open another PR with these changes |
Thanks @kidroca, that sounds good to me but I think it's best to await confirmation from @marcaaron in case this has wider repercussions (I'm unable to look any further into this myself currently). |
Tbh I'm having some trouble following the discussion. Maybe we should create a new issue as a next step so we can evaluate what is happening and what to do about it and who will do it? |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
🚀 [Deployed](https://github.com/Expensify/Expensify.cash
|
@parasharrajat, it seems like this PR cannot be tested without some code modifications, is that correct? If that's the case, this is not going to be testable on staging (at least not until the IOU beta is set up). Given that this page isn't visible on staging or production yet, I'm going to check it off in the deploy checklist. For future reference, when pull requests are not possible to QA on staging, the title of the issue should be prefixed with |
@roryabraham There is twist for this PR. Initially we started fixing the issue for Split bill page but then moved to manage the focus on the report action composer. To test it we can just switch the chat screen and drawer or open the modals and then close them. We have to check that the focus is not set automatically to the composer on mobile devices but it is set on the web and desktop. This eventually fix the clre issue linked to the PR. So it is testable but the instructions written on the description are for linked issue. |
Please review.
Details
ReportActionCompose
component has Controlled focus functionality. So when we close the modal we trigger the focus over the Keyboard onReportActiveCompose
. This behaviour was causing an issue when we navigate to the Split Bill page or possibly any other screen which we open from this button's modal.Fixed Issues
Fixes #1855 & Fixes #2377Tests/ QA steps
CreateMenu
'smenuItems
with the following on line L252.Open any chat and then open the Split Bill page from the icon's modal. The keyboard should not open as the Split bill page has an onscreen keyboard.
Tested On
Screenshots
Android
1616533120290.mp4