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

Enable Modern Drawer in react-navigation #11550

Merged
merged 35 commits into from
Oct 14, 2022

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Oct 3, 2022

Details

  • Upgrade to Modern drawer in react-navigation
  • Use react-freeze to prevent rendering issues caused by the upgrade (explained here)

Fixed Issues

$ #11426
$ #11479

Tests

  1. Navigate from the LHN to a chat and back several times (one that is in view and not in view)
  2. Via the Search page navigate to a chat (one that is in view and one not in view)
  3. Verify the navigation happens normally.
  • Verify that no errors appear in the JS console

PR Review Checklist

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 */
    • 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 reviewer 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
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 */
    • 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 (Web/Desktop)

  1. Open the app
  2. Verify that you can switch between chats using the LHN
  3. Open the search page
  4. Verify that you can switch chats using the chat switcher.

QA Steps (iOS/Android/mWeb)

  1. Open the app
  2. Open and close the same chat a few times. Verify that this happens quickly and you only see the "skeleton UI" the first time you open the chat (if at all). Be sure to use the swipe gesture as well as normal taps. While swiping, the other view that you're swiping in should be visible.
  3. Switch between chats quickly. You should briefly see the "skeleton UI" as you switch between chats. Again, be sure to test the swiping gesture as well as tap-only.
  4. Via the Search page navigate to a chat (one that is in view and one not in view)
  5. Verify the navigation happens normally.
  • Verify that no errors appear in the JS console

Screenshots

Web

2022-10-11_11-49-05.mp4

Mobile Web - Chrome

2022-10-11_12-33-39.mp4

Mobile Web - Safari

2022-10-13_13-24-30.mp4

Desktop

2022-10-11_12-03-28.mp4

iOS

2022-10-13_13-20-02.mp4

Android

2022-10-13_13-35-35.mp4

@marcaaron marcaaron self-assigned this Oct 3, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2022

Hey, I noticed you changed some webpack configuration files. This can break production builds. Did you remember to run a production build locally to verify they still work?

@melvin-bot

This comment was marked as resolved.

@marcaaron
Copy link
Contributor Author

Making pretty good progress with this PR. Though hitting a bit of a snag with the Android changes.

Though the initial animation happens now with much less delay it seems like the ReportActionsView unmounts, but the views do not get dropped on the Android side.

To prove this, I tried wrapping the methods that setState() on withOnyx() component in a setTimeout() and saw that the loading animation I've hooked up then works fine - so there's a traffic jam of some kind.

Without setTimeout() things are responsive when tapping - but the previous view hangs bad

XRecorder_03102022_164410.mp4

With the setTimeout() things work as intended. The previous view clears and the loading state is shown

XRecorder_03102022_165249.mp4

I'll keep looking into it tomorrow, but it seems like it would be useful to move these specific updates into the componentDidMount() of ReportActionsView

@hannojg
Copy link
Contributor

hannojg commented Oct 4, 2022

Hey @marcaaron, great progress!

I was assigned to look into upgrading to reanimated v3 in an effort toward enabling fabric.
I figured that your PR is essential for that upgrade, as it removes usage of REA v1 code (which v3 dropped support for).

I am not sure if one of your goals was to bump to REA v3 as well, however, I already created a PR for that, that is based on yours:
#11567

The most important commit is this one where I removed legacy setup code:
05f07b5

This could be very well also incorporated into your PR?

@marcaaron
Copy link
Contributor Author

I am not sure if one of your goals was to bump to REA v3 as well, however, I already created a PR for that, that is based on yours

Nice one! This was not a focus on my PR so I think we can HOLD the other one and wait for these changes perhaps. Or we can wait and see what happens with the force flag stuff in this Slack thread). I'm not sure when this will be ready to merge - I think I have to figure out some solution to the problems introduced when the Drawer was upgraded and then go from there.

@marcaaron
Copy link
Contributor Author

Ok, so looking into the issue @NikkiWines found and kind of confused about how this code is intended to work:

<FullPageNotFoundView
shouldShow={!this.props.report.reportID}

Unsure what situation we have were there is a report object but no report.reportID and why we are assuming the report is "not found" in that case. I tested this on main though and the behavior appears to be the same so I think it's not a blocker.

I was confused about this here -> https://github.com/Expensify/App/pull/10452/files#r983731454 as well and seems like it is getting resolved here.

roryabraham
roryabraham previously approved these changes Oct 13, 2022
Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

Overall this seems to work great

babel.config.js Outdated
@@ -12,6 +12,8 @@ const defaultPlugins = [
// source code transformation as we do not use class property assignment.
'transform-class-properties',

'@babel/plugin-proposal-export-namespace-from',
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to leave a comment noting why this babel plugin is needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was following this here -> https://docs.swmansion.com/react-native-reanimated/docs/next/fundamentals/web-support

But now realizing that is for the "next" version so maybe it's not needed.

@@ -121,7 +122,9 @@ class ReportScreen extends React.Component {
}

componentDidUpdate(prevProps) {
if (this.props.route.params.reportID === prevProps.route.params.reportID) {
const previousReportID = prevProps.route.params.reportID;
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB this change isn't really needed imo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, agree - I think I only changed it to help log some values.

>
{/* The isTransitioning variable here is necessary so that when we are retrieving the next report data
from Onyx the ReportActionsView will remount completely */}
{(this.shouldShowLoader() || isTransitioning)
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 just move the check into shouldShowLoader

@marcaaron
Copy link
Contributor Author

Ah so fun stuff - white screen is resolved now and there is a way to fix it h/t to @vladamx. I don't know why it didn't work when I tried it before but it works now. The result with a fake header component is pretty nice too.

2022-10-13_13-20-02.mp4

@marcaaron
Copy link
Contributor Author

Updated some things.

@marcaaron
Copy link
Contributor Author

Re-tested, but only changed the videos for Android and iOS since there is more or less no visual difference for web, desktop, etc.

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

Only one tiny comment

return (
<Freeze
freeze={this.props.isSmallScreenWidth && this.props.isDrawerOpen}
placeholder={(
<ScreenWrapper
style={[styles.appContent, styles.flex1, {marginTop: this.state.viewportOffsetTop}]}
Copy link
Contributor

Choose a reason for hiding this comment

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

Flex1 is a duplicate here – BaseScreenWrapper already has that style:

Suggested change
style={[styles.appContent, styles.flex1, {marginTop: this.state.viewportOffsetTop}]}
style={[styles.appContent, {marginTop: this.state.viewportOffsetTop}]}

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

  • 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 included screenshots or videos 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
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 */
    • 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.

@roryabraham
Copy link
Contributor

roryabraham commented Oct 14, 2022

iOS

RPReplay_Final1665707270.MP4

iOS Chrome

RPReplay_Final1665708134.MP4

iOS Safari

RPReplay_Final1665708285.MP4

Android

screen-20221013-175703_2.mp4

Android Chrome

screen-20221013-174746_2.mp4

Desktop Chrome

Screen.Recording.2022-10-13.at.5.43.19.PM.mov

macOS Desktop

Screen.Recording.2022-10-13.at.5.59.51.PM.mov

@roryabraham roryabraham merged commit 8a6bc17 into main Oct 14, 2022
@roryabraham roryabraham deleted the marcaaron-enableNonLegacyDrawer branch October 14, 2022 01:01
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @roryabraham in version: 1.2.15-2 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@trjExpensify
Copy link
Contributor

Yo! Coming from here, this looks like the most likely PR in the deploy checklist to cause this regression:

  1. Type a draft message in the chat composer
  2. Switch chats
  3. Observe the draft message remains in the composer

Will leave the DB label off for now until we get a gut check.

@hannojg
Copy link
Contributor

hannojg commented Oct 14, 2022

There is another regression with TextInputs. I opened an issue and PR at react-navigation already, so we'd be in the position to use a patch until they merge the changes.

Description of regression here: https://expensify.slack.com/archives/C035J5C9FAP/p1665727193558759
Issue ticket: react-navigation/react-navigation#10927

@Julesssss
Copy link
Contributor

Yeah, this seems to be confirmed now @trjExpensify

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @yuwenmemon in version: 1.2.15-3 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import {Platform, View} from 'react-native';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import {Freeze} from 'react-freeze';
Copy link
Contributor

Choose a reason for hiding this comment

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

@marcaaron why react-freeze isn't added to package.json ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the dependency exists in other packages we are using so it's in node modules.

return !getReportID(this.props.route) || isLoadingInitialReportActions || !this.props.report.reportID;

// This is necessary so that when we are retrieving the next report data from Onyx the ReportActionsView will remount completely
const isTransitioning = this.props.report && this.props.report.reportID !== reportIDFromPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

@marcaaron I know it's been a long time, but any chance you can help explain how the reportID from route params could be different than the reportID from the report that came from withOnyx? Since the key passed to withOnyx uses the reportID from the route param, I'd think that they could never be different. Trying to wrap my head around this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😅

I want to say something like:

  • the route changes
  • triggers a re-render
  • start fetching the report from Onyx
  • the report takes a long time to return
  • during that time this component will be "transitioning"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that explanation makes sense because if the props change then withOnyx callbacks won't necessarily return the report right away, but I'd have to do some debugging to see if it's still possible with all the changes since then.

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.

8 participants