Skip to content
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

[HOLD for payment 2022-03-22] [$1,000] Back arrow on chat doesn't work after decreasing the browser size - Reported by @Tushu17 #7091

Closed
mvtglobally opened this issue Jan 7, 2022 · 50 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Improvement Item broken or needs improvement.

Comments

@mvtglobally
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open app
  2. Navigate to any chat
  3. Resize browser window to mobile view

Expected Result:

User should be able to use Back button

Actual Result:

User is unable to use back button. User has to resize browser back to navigate to LHN

Workaround:

Unknown

Platform:

Where is this issue occurring?

  • Web

Version Number: 1.1.26-0
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

screen-capture.A.mp4

Expensify/Expensify Issue URL:
Issue reported by: @Tushu17
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1640369999109800

View all open jobs on GitHub

@MelvinBot
Copy link

Triggered auto assignment to @yuwenmemon (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@kakajann
Copy link
Contributor

kakajann commented Jan 9, 2022

@parasharrajat I think this issue is a side effect of this PR #6356

@parasharrajat
Copy link
Member

parasharrajat commented Jan 9, 2022

Ok. Thanks for pointing out @kakajann. Let this issue be triaged and we can find a solution.

@yuwenmemon yuwenmemon added the Improvement Item broken or needs improvement. label Jan 10, 2022
@yuwenmemon yuwenmemon added the External Added to denote the issue can be worked on by a contributor label Jan 10, 2022
@MelvinBot
Copy link

Triggered auto assignment to @bfitzexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@bfitzexpensify
Copy link
Contributor

Upwork posting here

Reporting job here @Tushu17

@MelvinBot
Copy link

Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (Exported)

@MelvinBot MelvinBot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 10, 2022
@MelvinBot
Copy link

Triggered auto assignment to @thienlnam (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@brianmuks
Copy link
Contributor

brianmuks commented Jan 13, 2022

I have been looking into this issue. The bug is coming from defaultStatus in the Drawer.Navigator component. The method that is handling the state of the defaultStatus returns true if the screen is small otherwise false. However, according to the documentation on https://reactnavigation.org/docs/drawer-navigator it states that the defaultStatus should always be set to open .

From the docs:

You can also specify other props such as drawerStyle based on screen size to customize the behavior. For example, you can combine it with defaultStatus="open" to achieve a master-detail layout.

Please let me know if this proposal sounds good so I can take on the job.

@parasharrajat
Copy link
Member

Would you like to link some code in our app? So that I know which component are you talking about?

@brianmuks
Copy link
Contributor

Would you like to link some code in our app? So that I know which component are you talking about?

@parasharrajat
Copy link
Member

Ok, Thanks.

The method that is handling the state of the defaultStatus returns true if the screen is small otherwise false.

I don't think this is correct.

@brianmuks
Copy link
Contributor

Ok, Thanks.

The method that is handling the state of the defaultStatus returns true if the screen is small otherwise false.

I don't think this is correct.

I tested the code and it's working just fine.

@brianmuks
Copy link
Contributor

Ok, Thanks.

The method that is handling the state of the defaultStatus returns true if the screen is small otherwise false.

I don't think this is correct.

Ok, Thanks.

The method that is handling the state of the defaultStatus returns true if the screen is small otherwise false.

I don't think this is correct.

https://www.awesomescreenshot.com/video/6823807?key=90ed83be4bafc44948931864ee2bffba

@parasharrajat
Copy link
Member

Proposal

After debugging I found out that changing the defaultStatus on Base causes the navigation to break.

it is happening when we remount the navigator and change the defaultStatus. defaultStatus is supposed to be a first-time value (not controlled) and changes to this prop, do not update the default status of the drawer. It is only used on the mount.

we need remounting to fix the layout issues when the browser is resized.

So to fix this issue, we have to make sure that we don't update the defaultStatus when the browser is resized.
Thus something like this fixes it and does not break navigation.

const BaseDrawerNavigator = (props) => {
    const [defaultStatus] = useState(Navigation.getDefaultDrawerState(props.isSmallScreenWidth));

    const content = (
        <Drawer.Navigator
            backBehavior="none"
            key={`BaseDrawerNavigator${props.isSmallScreenWidth}`}
            defaultStatus={defaultStatus}

I will use the class component.


I can tell that @brianmuks was close to finding the solution and his proposal, discussed about defaultStatus. But his explanation is not correct and his suggestions either break the navigation or ask to update the behavior of the prop. Thus I rejected his proposal.

But I consider his contributions to be valuable.

I would like to fix this issue cc: @thienlnam (Some discussion about the issue )

🎀 👀 🎀 C+ reviewed and proposed.

@thienlnam
Copy link
Contributor

Thanks for the proposal and the comment @parasharrajat. I've looked over your proposal and it looks good, and I agree that @brianmuks was close to finding the solution and had an investigation that proved useful to your proposal. With that being said, @parasharrajat You have the 🟢 from me to start on the PR and @brianmuks we're discussing a compensation for your efforts towards the solution

@brianmuks
Copy link
Contributor

Thanks for the proposal and the comment @parasharrajat. I've looked over your proposal and it looks good, and I agree that @brianmuks was close to finding the solution and had an investigation that proved useful to your proposal. With that being said, @parasharrajat You have the 🟢 from me to start on the PR and @brianmuks we're discussing a compensation for your efforts towards the solution

@thienlnam thanks for your consideration.

@parasharrajat
Copy link
Member

parasharrajat commented Feb 22, 2022

Update: I think the solution that I found is not sufficient. It does not work on the Desktop. I will debug more. But for now, I retract my review.

@thienlnam
Copy link
Contributor

It looks like this issue is back on the table and ready to take more proposals. @bfitzexpensify Could we get this doubled?

@MelvinBot MelvinBot removed the Overdue label Mar 3, 2022
@bfitzexpensify
Copy link
Contributor

You bet - doubled to $1,000.

@bfitzexpensify bfitzexpensify changed the title Back arrow on chat doesn't work after decreasing the browser size - Reported by @Tushu17 [$1,000] Back arrow on chat doesn't work after decreasing the browser size - Reported by @Tushu17 Mar 4, 2022
@parasharrajat
Copy link
Member

parasharrajat commented Mar 4, 2022

@thienlnam

Updated Proposal:

I spent more time debugging this. I found out the real cause of the issue.
TLDR:

The issue is caused by the wrong drawer history

history.push({
type: 'drawer',
status: 'closed',
});
.

This history is used to close the drawer when we navigate to the report screen so that users don't see LHN instead of chats. But this logic is incorrect.
Correct logic would be:
https://github.com/parasharrajat/Expensify.cash/blob/d99a95ca2a2e4a8f913961f5c933b4a54b3c7b08/src/libs/Navigation/CustomActions.js#L103-L114.

        // Force drawer to close
        // https://github.com/react-navigation/react-navigation/blob/94ab791cae5061455f036cd3f6bc7fa63167e7c7/packages/routers/src/DrawerRouter.tsx#L142
        const hasDrawerhistory = _.find(state.history || [], h => h.type === 'drawer');
        if (!hasDrawerhistory || currentState.type !== 'drawer') {
            history.push({
                type: 'drawer',

                // If current state is not from drawer navigator then always use closed status to close the drawer
                status: currentState.type !== 'drawer' || currentState.default === 'open' ? 'closed' : 'open',
            });
        }

React-navigation usage following logic to close the drawer and we should use the same. https://github.com/react-navigation/react-navigation/blob/94ab791cae5061455f036cd3f6bc7fa63167e7c7/packages/routers/src/DrawerRouter.tsx#L142

According to this,

  • if drawer default status is open, then only add the history to close it.
  • otherwise, remove the history,

In the change above, I am doing the following:

  1. If history already has drawer status, do not override it.
  2. If no history is present or the state is not from drawer navigation (i.e. RHN modals) then use closed status history to close the drawer.

I have tested it in the following scene:

  1. Open the app directly on the web. and navigate from both LHN and RHN in various combinations - ✔️
  2. Resize the browser to mobile view and try out navigations - ✔️
  3. Open the app directly on mobile view and run navigations - ✔️
  4. resize to desktop view - run navigations - ✔️

It works well. I found this solution after going through many iterations.

@thienlnam
Copy link
Contributor

@parasharrajat The proposal looks good to me, thanks for the thorough explanation!

@parasharrajat
Copy link
Member

PR is ready.

@thienlnam
Copy link
Contributor

@bfitzexpensify I've just merged the PR, leaving this note here for you once the PR is deployed and the regression period is complete

Tushu17 - Reporting payout - $250
brianmuks - Original assistance to help find solution - $250
parasharrajat - Issue completion - $1000

@botify botify added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Mar 15, 2022
@MelvinBot MelvinBot removed the Overdue label Mar 15, 2022
@botify botify changed the title [$1,000] Back arrow on chat doesn't work after decreasing the browser size - Reported by @Tushu17 [HOLD for payment 2022-03-22] [$1,000] Back arrow on chat doesn't work after decreasing the browser size - Reported by @Tushu17 Mar 15, 2022
@botify
Copy link

botify commented Mar 15, 2022

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.42-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2022-03-22. 🎊

@botify botify removed the Weekly KSv2 label Mar 22, 2022
@MelvinBot MelvinBot added the Daily KSv2 label Mar 22, 2022
@bfitzexpensify
Copy link
Contributor

Looks like the posts expired because they were posted a while back. Have recreated them:

@brianmuks please apply here

@parasharrajat please apply here

@brianmuks
Copy link
Contributor

Looks like the posts expired because they were posted a while back. Have recreated them:

@brianmuks please apply here

@parasharrajat please apply here

I have done so thanks.

@bfitzexpensify
Copy link
Contributor

Thanks! OK, all paid out and complete. Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Improvement Item broken or needs improvement.
Projects
None yet
Development

No branches or pull requests

9 participants