Skip to content

Remove close button from HeaderWithCloseButton#17963

Closed
staszekscp wants to merge 10 commits intoExpensify:navigation-refactorfrom
adamgrzybowski:remove-close-button
Closed

Remove close button from HeaderWithCloseButton#17963
staszekscp wants to merge 10 commits intoExpensify:navigation-refactorfrom
adamgrzybowski:remove-close-button

Conversation

@staszekscp
Copy link
Contributor

@staszekscp staszekscp commented Apr 25, 2023

Details

Removes close button from HeaderWithCloseButton component - expained here

Fixed Issues

$ #15850

Tests

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  • Verify that no errors appear in the JS console

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 the expected offline behavior in the Offline steps 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 tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • 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 is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review 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
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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 code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android

* test flatlist for android

* fix linter

* fix name

* fix not working features

* limit rerenders
@staszekscp staszekscp requested a review from a team as a code owner April 25, 2023 11:24
@melvin-bot melvin-bot bot requested review from puneetlath and removed request for a team April 25, 2023 11:24
@MelvinBot
Copy link
Contributor

@puneetlath Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@staszekscp staszekscp changed the title Remove close button Remove close button from HeaderWithCloseButton Apr 25, 2023
Copy link
Contributor

@puneetlath puneetlath left a comment

Choose a reason for hiding this comment

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

This mostly looks good to me. Just a few things:

  1. you have lint errors
  2. I don't think we should pass the onBackButtonPress prop if we're just setting it to Navigation.goBack since that is the default
  3. Let's make sure that we do the all-device testing and include videos since this touches so many components

cc @mountiny in case you want to review as well.

onDownloadButtonPress: () => {},
onCloseButtonPress: () => {},
onBackButtonPress: () => {},
onBackButtonPress: Navigation.goBack,
Copy link
Contributor

Choose a reason for hiding this comment

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

I notice that on a lot of components we set this prop to Navigation.goBack, but given that is the default, why even pass this prop at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. We should remove all redundant code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some cases the onBackButtonPress should bring user back to a previous step in a flow (some screens are implemented as "steps", therefore navigation is not used)

Copy link
Contributor

@0xmiroslav 0xmiroslav Apr 26, 2023

Choose a reason for hiding this comment

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

We can override this prop on those cases, but no need on normal cases as Navigation.goBack is already set as default value.
Your current branch has double Navigation.goBack for most screens. I know this is already existing code but we can remove all of them since Navigation.goBack is now set as default prop.

@puneetlath
Copy link
Contributor

@mountiny perhaps we want to get a C+ to test this PR as well?

@mountiny
Copy link
Contributor

Thanks @puneetlath

Lets fix the lint issues and we can run the internal release which will help with testing. this should mainly remove the X button from all the RHP pages so there should not be a big problem hopefully

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Thanks! Asking for a C+

onBackButtonPress: () => {},
onBackButtonPress: Navigation.goBack,
onThreeDotsButtonPress: () => {},
shouldShowBackButton: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there any place where the shouldShowBackButton was false? are we covering that case?

Copy link
Contributor

Choose a reason for hiding this comment

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

This cannot be removed. i.e. ReportScreen have conditional back button render based on this prop.

Copy link
Contributor

Choose a reason for hiding this comment

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

There we go

@0xmiroslav
Copy link
Contributor

@staszekscp please run npm run lint and fix all lint errors like this:
'reportID' is assigned a value but never used

onThreeDotsButtonPress: () => {},
shouldShowBackButton: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

This cannot be removed. i.e. ReportScreen have conditional back button render based on this prop.

onDownloadButtonPress: () => {},
onCloseButtonPress: () => {},
onBackButtonPress: () => {},
onBackButtonPress: Navigation.goBack,
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree. We should remove all redundant code.

<HeaderWithBackButton
title={props.translate('reimbursementAccountLoadingAnimation.oneMoment')}
onCloseButtonPress={Navigation.dismissModal}
shouldShowBackButton={props.network.isOffline}
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this cause regression? I think it was intentional to set props.network.isOffline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I've noticed that if we remove X icon from every modal we won't have a chance to dismiss/go back and users would get stuck... That's why I decided to remove the shouldShowBackButton prop.

We can provide it conditionally (the default could be true to avoid passing the prop to almost every component), but then there should be some kind of mechanism to allow users to go back. Maybe we could leave conditional X button?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's why I decided to remove the shouldShowBackButton prop

Report screen doesn't need back button on web but on mobile, so this prop is necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And it seems to be working fine with this implementation - the back button is only visible on small screen (on wide web there is no back button as expected)

Copy link
Contributor

Choose a reason for hiding this comment

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

RHP modal screens still need back button even on web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the small screen the button is visible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually ReportScreen uses another component called HeaderView to render the back button, so this PR shouldn't affect it at all

Copy link
Contributor

Choose a reason for hiding this comment

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

So you still suggest to remove shouldShowBackButton prop completely and always show back arrow right?
I will check and confirm if any other pages need this button hidden.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are fine to deprecate shouldShowBackButton prop and always show back button because close button is no longer visible.
i.e. Settings page had close button but now that it's removed, no way to close this on web. Clicking outside is the only way.

Screenshot 2023-04-26 at 11 22 56 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

You can also click the UP/Back button to close it so we are good here!

@mountiny
Copy link
Contributor

Thanks for the discussion so far, running an internal build so this is a bit easier to test https://github.com/Expensify/App/actions/runs/4811973135

@OSBotify
Copy link
Contributor

@mountiny
Copy link
Contributor

Tested the build on web and on my ihone and it looks great ot what I can see
image

There is this skeleton issue with LHN on iOS for me
IMG_7944, not sure if this issue will be fixing it #17962

Copy link
Contributor

@0xmiroslav 0xmiroslav left a comment

Choose a reason for hiding this comment

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

Request money pages still have close button

Screenshot 2023-04-26 at 11 25 27 PM

Screenshot 2023-04-26 at 11 25 34 PM

Screenshot 2023-04-26 at 11 25 40 PM

<HeaderWithBackButton
title={props.translate('reimbursementAccountLoadingAnimation.oneMoment')}
onCloseButtonPress={Navigation.dismissModal}
shouldShowBackButton={props.network.isOffline}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are fine to deprecate shouldShowBackButton prop and always show back button because close button is no longer visible.
i.e. Settings page had close button but now that it's removed, no way to close this on web. Clicking outside is the only way.

Screenshot 2023-04-26 at 11 22 56 PM

@0xmiroslav
Copy link
Contributor

Is it expected to show back button and deprecate close button even on this kind of modal?

Screenshot 2023-04-26 at 11 27 52 PM

@0xmiroslav
Copy link
Contributor

Not related to this PR but this regression is caused by navigation refactor and should be fixed:
Drop to upload feature broken
Let's create a follow-up issue for this so we don't miss it.

Screen.Recording.2023-04-26.at.11.32.00.PM.mov

@mountiny
Copy link
Contributor

Is it expected to show back button and deprecate close button even on this kind of modal?

Oh good catch, I think the attachement modal on desktop should have X it makes more sense than <

but mobile would still have the <

@0xmiroslav
Copy link
Contributor

@staszekscp please fix merge conflict.

Also, I think we should re-think about shouldShowBackButton prop.

Is it expected to show back button and deprecate close button even on this kind of modal?

Oh good catch, I think the attachement modal on desktop should have X it makes more sense than <

but mobile would still have the <

Based on this, we may still need both shouldShowBackButton and shouldShowCloseButton prop.

@mountiny
Copy link
Contributor

@0xmiroslav I would say if the attachment modal is the only place we found, I think we dont need that and we could make some custom wrapper fro that header. I think eventually we will drop usage of that modal and the gallery for pictures will be more common to what you are used to from whatsapp or messenger.

@0xmiroslav
Copy link
Contributor

@0xmiroslav I would say if the attachment modal is the only place we found, I think we dont need that and we could make some custom wrapper fro that header. I think eventually we will drop usage of that modal and the gallery for pictures will be more common to what you are used to from whatsapp or messenger.

Send attachment design will also change?

@mountiny
Copy link
Contributor

mountiny commented Apr 27, 2023

I would imagine, this is not being worked on yet. But yeah, we need to keep it for now so whatever is easier now, keep the props and use it only in the attachment modal or something else. We need it there.

btw created an issue here #18064

@staszekscp
Copy link
Contributor Author

There are actually two modals where the X button could be applied. I think we could add a prop showCloseButton and display it conditionally depending on screen size there. Let me do that tweak quickly

@staszekscp
Copy link
Contributor Author

You may have a look now after some cleanup and fixes :)

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

This is looking good to me
image

I have noticed this one little bug on pronouns page and create issue for it so we dont forget #18092 lets not fix it here

@0xmiroslav would you be able to go through the checklist here please? thank you!

Copy link
Contributor

@0xmiroslav 0xmiroslav left a comment

Choose a reason for hiding this comment

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

I see you changed FlatList/index.android.js. Is this relevant to this issue?

Comment on lines +66 to +71
/** Whether we should show a close button */
shouldShowCloseButton: PropTypes.bool,

/** Method to trigger when pressing close button of the header */
onCloseButtonPress: PropTypes.func,

Copy link
Contributor

Choose a reason for hiding this comment

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

Please put this in original order for no code diff

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we deprecate onCloseButtonPress and use onBackButtonPress always as there's no case of both back button and close button show

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's an edge case in two modals, so I decided to keep it for the web

Copy link
Contributor

@0xmiroslav 0xmiroslav left a comment

Choose a reason for hiding this comment

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

These change original behavior. As they were added intentionally, let's make sure that there aren't any regressions after these removals.

title={this.props.translate('common.description')}
shouldShowBackButton
onBackButtonPress={Navigation.goBack}
onCloseButtonPress={this.onCloseButtonPress}
Copy link
Contributor

Choose a reason for hiding this comment

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

There was IOU.setMoneyRequestDescription(''); call when close page.

<HeaderWithBackButton
title={this.props.translate('workspace.invite.invitePeople')}
subtitle={policyName}
onCloseButtonPress={() => this.clearErrors(true)}
Copy link
Contributor

Choose a reason for hiding this comment

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

There was this.clearErrors(true) call when close page

title={titleForStep}
shouldShowBackButton={shouldShowBackButton}
onBackButtonPress={isEditingAmountAfterConfirm ? () => navigateToStep(moneyRequestStepIndex) : navigateToPreviousStep}
onBackButtonPress={currentStepIndex === 0 ? Navigation.dismissModal : navigateBack}
Copy link
Contributor

Choose a reason for hiding this comment

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

There was conditional navigation, so if isEditingAmountAfterConfirm = true, should navigate to request step

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic is still present, I just decided to move it to navigateBack instead

<HeaderWithBackButton
title={props.translate('initialSettingsPage.about')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS)}
Copy link
Contributor

Choose a reason for hiding this comment

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

When navigate to this page directly, it simply closes. Before, it went to Settings page always.

<HeaderWithBackButton
title={props.translate('common.payPalMe')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_PAYMENTS)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

<HeaderWithBackButton
title={this.props.translate('timezonePage.timezone')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_TIMEZONE)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

<HeaderWithBackButton
title={this.props.translate('closeAccountPage.closeAccount')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_SECURITY)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

<HeaderWithBackButton
title={props.translate('initialSettingsPage.security')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

<HeaderWithBackButton
title={props.translate('workspace.common.workspace')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

<HeaderWithBackButton
title={this.props.translate('common.workspaces')}
shouldShowBackButton
onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@mountiny
Copy link
Contributor

mountiny commented May 4, 2023

@staszekscp lets get this one ready for review and merge it so we can continue with the UP implementation.

@staszekscp
Copy link
Contributor Author

Hey, I've applied requested changes to this PR, because it is needed to continue work with the navigation reboot :)

@mountiny
Copy link
Contributor

mountiny commented May 5, 2023

Closing in favour of #18402

@puneetlath thanks for a review, if you are interested please feel free to review there

@mountiny mountiny closed this May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants