-
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
Switching between chats using LHN causes chats to get stuck offscreen #2051
Comments
Hello @tylerkaraszewski, I would love to look into this. |
Hi, This is Kaushik here. I would like to put a technical explanation for this,
|
There's a good chance this might be solved by the loading transition proposed here: #2154, I can take a look, when I start working, and report back |
I'm not sure how to solve this yet but, it seems like it would be related to the |
I've found another way to recreate it:
2021-04-01.15-41-29.mp4I think I found what's causing it: Removing this fixes the issue when you tap the search icon or when you open a new chat. In summary the issue seems related to focusing, focusing quickly on a field during animation causes this, but it's perhaps something that should be addressed in React Navigation Using the InteractionManager like this does not help: InteractionManager.runAfterInteractions(() => {
this.textInput.focus();
}); ...and (am I getting annoying with this 😄) removing input autofocus on mobile (mWeb as well, aka small screens) would "fix" this You can use desktop safari for more debugging options |
@marcaaron - what do you think about this analysis? |
I'm not able to reproduce this. But if disabling the "auto focus" behavior will fix it then we are discussing this possibility here and if we do decide to remove the auto focus for inputs on mobile then this should be fixed by default. cc @trjExpensify since this is another potential issue related to auto focus. |
I tested it. Autofocus has nothing to do with it. It still exists. Easier reproduction for this is to try to change the resolution in a responsive mode in the browser. bug.mp4 |
That's a bit harsh Changing the size dynamically might be another way to cause this problem. Autofocus.issues.mp4 |
I've researched the handling of input fields in mobile Safari further. When an input is focused mobile Safari would try to position it nicely in the middle for the user Here is a good explanation: https://gist.github.com/kiding/72721a0553fa93198ae2bb6eefaa3299
And here's the same problem reported on stackoverflow: https://stackoverflow.com/a/6918582/4834103
Why does calling focus() break my CSS transition? Changing the viewport dimensions might be causing the same issue, but I think it's a lot less likely to happen IRL |
There's a ticket related to viewport size change on react navigation: react-navigation/react-navigation#8551 Thought specifically for the autofocus cases:
I've also recreated this on mobile Chrome |
It does seem like perhaps the fix would be in Not sure if |
I am somewhat convinced that slow running JS is the culprit here and wonder if just delaying the render of the |
Well it runs really well and smooth on a real device. On my video you can see that the drawer is not involved - I use the FAB to start a new chat - which transitions to a modal navigator. Same thing with Search I can't recreate the issue when switching chats |
I've played with the Regarding slow js, I found a thing but I don't know where to post it:
The point is there would be a lot of You can still have a A single element wraps the main layout - the way the Some numbers
I can open a separate ticket about this if you'd like |
This behavior maybe seems OK for web/mWeb where there is no swipe gesture? And the problem doesn't exist on native so maybe this could help.
Ah yes, I've thought about this before, but have not investigated the impacts (some benchmarks would be helpful if you decide to create an issue). I did look into whether there is some event delegation to handle this on the |
The optimization won't reduce these counts, but will remove additional instantiation of classes, allocating memory, and running their lifecycle methods E.g. Instead of calling 100 times componentDidMount it will be just 1 |
Sounds nice! Maybe try to test and benchmark so we have some idea of how much it can help? In any case, I would love to see an issue for it 👍 |
Could be, but would add yet another Platform specifying handling Removing focus on the other hand... 😄 Screen.Recording.2021-04-09.at.0.24.02.movStill behaves smooth (this is DEV ⬆️) |
@kidroca with respect to the above, If you could put a check in the Event listeners so they fire on each render. It would save a lot of computations. |
Sorry I didn't get that. The problem is not that |
Yeah, Correct. I think putting it in context would stop its triggering(Currently it fires a lot). |
Create a ticket about |
ProposalIt seems you want this fixed, but dropping auto focus on mobile is not a suitable solution for you Here's a proposal in that direction: A potential fix might be to encapsulate logic inside the // from: import { useFocusEffect } from '@react-navigation/native';
useFocusEffect(() => {
// This code would run when a screen containing THIS TextInputFocusable is focused
if (props.autoFocus) {
textInput.focus();
// the uglier version (in case the above doesn't work) is to focus after a brief `setTimeout`
// (hook logic should be added to clear pending timers)
}
}) The code above would run for a Actually disregard the useFocusEffect(
React.useCallback(() => {
const task = InteractionManager.runAfterInteractions(() => {
textInput.focus();
});
return () => task.cancel();
}, [])
); I'm using the hook syntax for simplicity this can be recreated with a HOC, though it was agreed that in situations like this one it might be for the best to just use hooks
The ticket mentioned above #2326 could also be considered as when the keyboard appears all the dimension listeners from |
I'm not sure that's correct. Pretty sure we have unanimously come to the decision that we should stop auto focusing this input when we open up to a new chat (on mobile and mobile web at least). I'm curious though, after the |
Then it would be even easier.
Yes, it doesn't happen 100% of the time, but it would still happen (mobile web Safari). I'm using webpack dev server, though, for a prod build it might happen less often |
Since autofocus still happens on mobile web this issue still occurs: Autofocus still happens when switching chats due to: Autofocus still happens on FAB -> search, or FAB -> new chat because: Earlier I've provided info on how autofocus is causing this issue. Since it is decided that on mobile and mWeb fields should not be focused automatically addressing the remaining input focus issues would fix this bug as well. ProposalRefactor Defaulting field autoFocus to Fix the on mount code of Simply removing the call to focus is enough as the Since we modify the default props autoFocus can be overriden if necessary by the parent component using Update the code in the Or Update the Whichever is easier and makes more sense This would allow reuse and cut down repetitive code
Edit: the logic actually would have to stay because of the modal handling: I need to think this a bit more, but there might be a way to address this more elegantly, or not addressed at all for the moment |
@kidroca It does seem to improve things quite a bit and also that behavior to focus on mount in Anyways, I think this is a good improvement and just removing the One thing I've also noticed is that when a new report is loaded this can also cause re-renders in the |
@marcaaron It's worth mentioning that it has been removed already. #2528 |
Yes, I that was my initial thought but seeing that |
Couldn't the |
I'll take a look too |
Sorry @kidroca let's actually hold since maybe there is not much more that needs to be done if this has already been fixed. |
@marcaaron Only the code in The autofocus inside the This needs to be updated so that autofocus happens only on desktop/web. It would be better to have this behavior encapsulated in |
@kidroca This is has been taken care of by #2505. But moreover, I think autofocus is one factor and there are also other involved factors that are causing this issue. If you try to resize the browser window you can again reproduce this issue. Other than this I noticed is that we should debounce the dimension changes which is really causing a lot of calculations Also only emit the changes when they actually change by checking the state changes here by putting an if the check for previous and new values.
|
Ok so "no autofocus" on mobile is not 100% true This will still auto focus on all platforms this.interactionHandle = InteractionManager.runAfterInteractions(() => {
this.textInput.focus();
}); As Marc pointed out
The issue would probably still occur on mobile safari |
I've added measurements on the effect of dimension changes in the ticket here: #2326 |
To clarify, I'm not sure this has actually been decided. The case that we are discussing here is switching between chats. |
Ok so this ticket is only about switching chats and the "Search", "New Chat", "New Group Chat" will be handled separately, or you mean focus handling for them is not decided yet? Just want to point out that all the "discoveries" here are related to "Search", "New Chat", "New Group Chat" and the issue is the same - a transition that involves immediate focus causes the "stuck offscreen" bug |
Both of those statements are correct. This issue is related to switching chats (seems to be fixed now). As for disabling input focus on other screens I think probably it would be best to get some other opinions. |
Sorry, I'm not talking about that autofocus would necessarily need to be removed on those screens, but the same "stuck offscreen" bug would remain for them The same issue occurs when you use the FAB, but I don't think there's a separate ticket about it, I thought this ticket would address it as well. I've brought that up a couple of times: #2051 (comment) 2021-04-01.15-41-29.mp4Also if autofocus should stay for the "Search", "New Chat", "New Group Chat" ... I've made another proposal that can keep autofocus and still fix the bug: #2051 (comment) Anyway I'll wait for things to get cleared out |
Ok sorry for all the back and forth here, but I think what we should do at this point is close this issue and create a new one so we can:
Apologies for the confusion here. I should have encouraged us to create a new issue for that earlier, but assumed they would have the same root cause. Given that the main issue here is fixed, but the other is not we should create a new one. |
@kidroca do you want to create the new issue, propose a solution, then fix it? If so, you'll be eligible for the $150 bonus |
Yeah, I'll open a new ticket next week. We'd have to discuss this there before a proposal can be made:
|
If you haven’t already, check out our contributing guidelines for onboarding!
Expected Result:
When switching between chats in mobile web for E.Cash, I expect the chat to load and display correctly
Actual Result:
When switching between chats in mobile web for E.cash in Chrome on iOS, the second chat you switch to is not displayed correctly, and is off-screen
Action Performed:
Workaround:
You are forced to reload the page.
Platform:
Web: No
iOS: No
Android: No
Desktop App: No
Mobile Web: iOS - Yes | Android - No
Version Number: v1.0.2-73
Notes/Photos/Videos: Any additional supporting documentation
Here's a short recording of this happening:
Here's how the chat renders:
https://www.upwork.com/jobs/~01a09bd14ffed37ba9
https://github.com/Expensify/Expensify/issues/157743
The text was updated successfully, but these errors were encountered: