App: [HOLD for payment 2024-04-05] [$100] Remove the closeFullScreen() method from code since it is no longer used
The back button was removed from the modals and so now the closeFullScreen() method is no longer used in the code, but it was never removed. Let’s remove it!
Old Issue Description
If you haven’t already, check out our [contributing guidelines](https://github.com/Expensify/ReactNativeChat/blob/main/contributingGuides/CONTRIBUTING.md) for onboarding and email contributors@expensify.com to request to join our Slack channel! ___Version Number: v1.4.41-3 Reproducible in staging?: y Reproducible in production?: y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Slack conversation:
Action Performed:
Precondition:
- Workspace filter is set to “Expensify”.
- Go to staging.new.expensify.com
- Go to any chat and send a message.
- Open workspace switcher.
- Select any workspace.
- Click Profile settings.
- Click back button on the top left.
Expected Result:
App closes profile settings and reopens the chat that shows up after switching workspace in Step 4.
Actual Result:
App reopens the chat that is opened in Step 2, which is before workspace filter is applied, while the workspace filter is still applied.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
- Android: Native
- Android: mWeb Chrome
- iOS: Native
- iOS: mWeb Safari
- MacOS: Chrome / Safari
- MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/Expensify/App/assets/93399543/32828cc3-8d1c-4347-a25d-f7b624a03ccc
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~0124a682d645bc91de
- Upwork Job ID: 1757785433393643520
- Last Price Increase: 2024-03-15
Issue Owner
Current Issue Owner: @adelekennedyAbout this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 64 (30 by maintainers)
The
StackActions.popfunction goes back to the previous screen. The problem with it is, that it is noticeably slow. Switching topopToTophelped, but apparently, it introduced this bug.We can consider switching back to the
.popfunction, however, this will result in a slower performance (and that is probably not what we want). On the other hand, pressing the browser back button is also slow (the performance is similar to what we have with the.popfunction).So the aim is, to find a solution, which will be both performant and not use the
popToTopfunction.Let’s hire @barros001 because they were first to mention the root cause? https://github.com/Expensify/App/issues/36509#issuecomment-1961909146
@tgolen 🎀👀🎀
looks like it worked this time!
@adelekennedy offer accepted
EDIT: Spoke too soon, looks like Upwork having issues and I can’t accept it… I’ll try again shortly.
That’s a good point. It’s a shame that
closeFullScreenhas been abandoned. It should be cleaned up now. I’m going to reduce the bounty of this issue to $100 and change the scope to just be a simple cleanup.@tgolen I think we should measure the delay of
StackActions.popvsStackActions. popToTop.If the delay is measureable and user can feel the lag, then we could go with @bi-kash’s proposal because I can’t find this issue happening anywhere else in the app.
No worries, it’s all good 😃
OK, I read through most of this issue and I hope I caught everything. I understand the focus on
popandpopToTopbut I am concerned that it could have far-reaching effects across the app. Are we sure we want to affect the entire app?If so, then I think this problem is not really related to the workspace selector only, and that’s just one way the problem is manifesting. I agree with Rushat’s plan to fix that.
If we don’t want to affect the entire app, then @bi-kash’s proposal is the correct one I think.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Clicking the back button in profile settings will not take you back to the same conversation.
What is the root cause of that problem?
The root cause of this problem is this commit: https://github.com/Expensify/App/commit/404b0b65ec58bbe3b072d366d78f266f8de832bd
It replaced
popwithpopToTopwhich makes the navigator navigate back to the first screen and not the previous one.What changes do you think we should make in order to solve the problem?
Reverting https://github.com/Expensify/App/commit/404b0b65ec58bbe3b072d366d78f266f8de832bd is not really an option here because the change was made to solve another problem. We can also see by this comment that
popis the right method to call here but it does cause delays, which we also don’t want.I also found some interesting things when using
pop(this only applies to Web). For example, when we usepop, we the browser’s forward navigation will activate, which means the pop behaves similarly to the browser’s back button. If you go to settings, then navigate to Wallet, then Preferences, then Security and then click the back button, you’d be able to hit forward and backtrack these steps (although it doesn’t appear to always be that way). WithpopToTop, nont of this happens. It behaves as we would expect, it pushes a new url to the history and you can hit back on the browser’s button to go back to the settings back, etc… Except that it does not work 😃Going back to the OG problem, where
popadds a delay, I found this commit that’s interesting:https://github.com/react-navigation/react-navigation/commit/b1f13774295465942aafa1b0ff611b9eebccbd77
Looks like
react-navigationadds some artificial delay when navigating under certain codnitions. I didn’t dig too deep but this could be the reason why we see a slight delay when usingpop.So,
popToTopis not the correct method, it doesn’t do what we need, and whilepopdoes, it has a delay and on web it acts as clicking the browser’s back button which IMO is wrong. Clicking the < button on the app shouldn’t bring us “back”, we’re moving “forward” to the previous url, if that makes sense.My proposed solution for this problem is to rewrite
closeFullScreento be like this:This will use the
pushmethod to navigate usforwardto the previous screen, but grabbing the previous screen in the stack and navigating to it. This will make the app navigate to the correct page, without the delay and as a bonus will not break the browser’s back/forward navigation.The check for
length < 2was added as a failsafe but I believe that scenario won’t happen, especially becausecloseFullScreenis only used in one place throughout the entire codebase.EDIT: This doesn’t really work well on mobile because hitting back is “navigating forward” and the navigation animation is not correct. Also, I believe using
pushadds another stack on top and I don’t think this is a good thing as we want to remove the top screen out of the stack instead of adding another screen on top of it. I’ll leave this proposal up as there might still be some good info in here.What alternative solutions did you explore? (Optional)
Proceed with reverting https://github.com/Expensify/App/commit/404b0b65ec58bbe3b072d366d78f266f8de832bd and dealing with the delay issue separately. The original fix for the delay issue was wrong and should be reverted and a new fix for the delay should be created.
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The current issue pertains to the functionality of the back button in profile settings, which erroneously navigates to the conversation before workspace switching.
What is the root cause of that problem?
When the user selects a workspace from the workspace switcher, The code first executes Navigation.goBack(), navigating to the previous screen in the stack. And only after that it checks if it has to switch to new screen.
What changes do you think we should make in order to solve the problem?
Instead of unconditionally navigating back to the previous screen, We only navigate to the previous screen if and only if the user selects the same or active workspace. Otherwise, it directly navigates to the new workspace.
Here If a new workspace was selected, the first screen of that new workspace will be the “top” of the stack, since we’re not navigating back before switching workspace.
Updated Result:
https://github.com/Expensify/App/assets/32809050/2780ecfe-b3d9-4035-a479-8ccc9ee34754
What alternative solutions did you explore? (Optional)
We can simply use .pop() instead of .popToTop(). However, it is too slow. So above solution is fast and robust and solves the problem from the root.