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

Fix Issue 9253: Previous chat username is displayed when you navigate back from different chat #10069

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

ntdiary
Copy link
Contributor

@ntdiary ntdiary commented Jul 24, 2022

Details

Proposal option 1
Just show blank page when backing

Fixed Issues

$ #9253

Tests

This problem only occurs on mobile web platform.

  1. Go to localhost:8080
  2. Log in with an account that has multiple chats.
  3. Open any chat.
  4. Add a new tab and go to localhost:8080 ( you have logged in in the step 2 ).
  5. Open a different chat from step 3.
  6. Click the browser's back button ( or use the back gesture in android platform)
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

QA Steps

This problem only occurs on mobile web platform.

  1. Go to staging.new.expensify.com
  2. Log in with an account that has multiple chats.
  3. Open any chat.
  4. Add a new tab and go to staging.new.expensify.com ( you have logged in in the step 2 ).
  5. Open a different chat from step 3.
  6. Click the browser's back button ( or use the back gesture in android platform)
  • Verify that no errors appear in the JS console

Screenshots

Web

macos-chrome.mp4

Mobile Web

android chrome
android-chrome.mp4
ios safari
ios-safari.mp4

Desktop

macos-desktop.mp4

iOS

ios-native.mp4

Android

android-native.mp4

@ntdiary ntdiary requested a review from a team as a code owner July 24, 2022 10:20
@melvin-bot melvin-bot bot requested review from AndrewGable and mananjadhav and removed request for a team July 24, 2022 10:20
@github-actions
Copy link
Contributor

github-actions bot commented Jul 24, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@ntdiary
Copy link
Contributor Author

ntdiary commented Jul 24, 2022

I have read the CLA Document and I hereby sign the CLA

@ntdiary ntdiary closed this Jul 24, 2022
@ntdiary ntdiary reopened this Jul 24, 2022
Copy link
Collaborator

@mananjadhav mananjadhav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look fine. Thanks for the signed commit @ntdiary.

I had troubles with reproducing this even back then. Do you have anything specific in the QA steps that makes it easier for me or the QA to reproduce the issue?

@ntdiary
Copy link
Contributor Author

ntdiary commented Jul 26, 2022

Hi @mananjadhav, I'll try to demonstrate it in Chrome Device Mode to better explain the steps,
this is similar to Safari and Android Chrome.
Please feel free to let me know if there is anything unclear. 🙂

  1. Make sure you are logged out in browser.
  2. Add a New Tab
  3. Open the Chrome Dev Tools and Device Mode like this
  4. Enter the URL in the address bar such as localhost:8080, and login the account
  5. And now, the current URL is http://localhost:8080/r/96188031 96188031 in the URL path represents the report ntdiary+1 (we can see it on the right panel), we should avoid opening this report in the step 7 .
  6. Click Reload Button to refresh this page
  7. Click another report except the ntdiary+1. Here I chose the [email protected], and then URL changed to this http://localhost:8080/r/96403444.
  8. Click the back button here
  9. now the URL immediately changed back to the original path http://localhost:8080/r/96188031, the page was first rendered as the contents of ntdiary+1, and then back to the chat list like this
demo.mp4

@ntdiary
Copy link
Contributor Author

ntdiary commented Jul 28, 2022

Hi, this might be an easier way ( in mobile web ):

  1. Go to staging.new.expensify.com
  2. Log in with an account that has multiple chats.
  3. Open any chat.
  4. Add a new tab and go to staging.new.expensify.com ( you have logged in in the step 2 ).
  5. Open a different chat from step 3.
  6. Click the browser's back button ( or use the back gesture in android platform), we'll see the previous username in a moment

@ntdiary
Copy link
Contributor Author

ntdiary commented Aug 4, 2022

Hi, @mananjadhav, can you reproduce the issue with the latest steps? 🙂

@mananjadhav
Copy link
Collaborator

I was OOO last week, getting to this by tomorrow. Can you please resolve conflicts @ntdiary meanwhile? thank you for your patience on this one.

@ntdiary
Copy link
Contributor Author

ntdiary commented Aug 10, 2022

@mananjadhav resolved. 🙂

@mananjadhav
Copy link
Collaborator

@mananjadhav resolved. 🙂

Right on time. Thanks, just pulled your changes to review and test. Will send an update soon.

Can you reproduce the issue with the latest steps?

Thanks @ntdiary, these steps are much clearer and reproducible. Appreciate it.

@mananjadhav
Copy link
Collaborator

@AndrewGable I tested this on iOS Simulator Safari for mWeb. (tested on all platforms). Changes look fine.

The only thing I am not sure if contextType will have any impact anywhere. @AndrewGable if you can help with that once, it'll be great.

🎀 👀 🎀 
C+ reviewed

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Copy link
Collaborator

@mananjadhav mananjadhav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndrewGable AndrewGable merged commit 972b835 into Expensify:main Aug 10, 2022
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@marcaaron
Copy link
Contributor

Hey! I came across this change because I am working on an issue to refresh the report on network reconnect when the sidebar is open. This solution has an issue where it breaks some existing behavior since it forces the report page to unmount when the sidebar is revealed. There is quite a bit of code in ReportActionsView that expects the report the stay mounted and not get unmounted. This code in particular does not seem like the behavior we want.

if (this.props.isSmallScreenWidth && this.context === 'open') {
return null;
}

@marcaaron marcaaron mentioned this pull request Aug 22, 2022
93 tasks
@ntdiary
Copy link
Contributor Author

ntdiary commented Aug 23, 2022

Hi, sorry for that, I didn't expect such a problem.
If we want to keep the child component mounted, we can use visibility, like this:

diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js
index e46a4ed27..ea09a4eb0 100644
--- a/src/pages/home/ReportScreen.js
+++ b/src/pages/home/ReportScreen.js
@@ -198,9 +198,7 @@ class ReportScreen extends React.Component {
             return null;
         }

-        if (this.props.isSmallScreenWidth && this.context === 'open') {
-            return null;
-        }
+        const visibility = (this.props.isSmallScreenWidth && this.context === 'open') ? styles.visibilityHidden : {};

         // We let Free Plan default rooms to be shown in the App - it's the one exception to the beta, otherwise do not show policy rooms in product
         if (!Permissions.canUseDefaultRooms(this.props.betas)
@@ -221,7 +219,7 @@ class ReportScreen extends React.Component {
             reportClosedAction = lodashFindLast(this.props.reportActions, action => action.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED);
         }
         return (
-            <ScreenWrapper style={[styles.appContent, styles.flex1, {marginTop: this.state.viewportOffsetTop}]}>
+            <ScreenWrapper style={[styles.appContent, styles.flex1, {marginTop: this.state.viewportOffsetTop}, visibility]}>
                 <HeaderView
                     reportID={reportID}
                     onNavigationMenuButtonClicked={() => Navigation.navigate(ROUTES.HOME)}

This way we can both fix this issue and keep the report mounted.
styles.visibilityHidden is already compatible with native app and mobile web,
and this issue also only occurs on mobile web (small screen).

@AndrewGable
Copy link
Contributor

Reverted

@ntdiary
Copy link
Contributor Author

ntdiary commented Aug 23, 2022

Hi @AndrewGable, the latest solution can work well for these scenarios in my test, should I submit a new PR later ? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants