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

17548: Personal details push to page #18424

Closed

Conversation

gedu
Copy link
Contributor

@gedu gedu commented May 4, 2023

Details

Updated dropdowns fields to be MenuItems which sends the user to another page to pick the option
Standarized the spaces between Inputs, created a new FormSpace component.

Fixed Issues

$ #17548
PROPOSAL: #17548 (comment)

Tests

Errors on Empty State

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Save
  4. All the Inputs even the Menu Items should show a required field error

Update the menu Country item (no USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select a new country (no USA)
  5. The Country Item should show the selected Country
  6. The State Input should be an input component
  7. You can select new ones and the Menu Item should be updated

Update the menu Country item (USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select United State
  5. Should send you back and the Country Item should show the selected Country
  6. The State Input should be a Menu Item

Update the menu State item (USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select United State
  5. The Country Item should show the selected Country
  6. Clicking on the State menu should send you to a new Page
  7. You can select any State
  8. Should send you back to and show you the updated State

Autocomplete address

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Start filling the Address Line 1, a suggestion menu should shows up
  4. Clicking on any address should autocomplete, menu items and inputs
  • Verify that no errors appear in the JS console

Offline tests

Errors on Empty State

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Save
  4. All the Inputs even the Menu Items should show a required field error

Update the menu Country item (no USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select a new country (no USA)
  5. The Country Item should show the selected Country
  6. The State Input should be an input component
  7. You can select new ones and the Menu Item should be updated

Update the menu Country item (USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select United State
  5. Should send you back and the Country Item should show the selected Country
  6. The State Input should be a Menu Item

Update the menu State item (USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select United State
  5. The Country Item should show the selected Country
  6. Clicking on the State menu should send you to a new Page
  7. You can select any State
  8. Should send you back to and show you the updated State

QA Steps

Errors on Empty State

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Save
  4. All the Inputs even the Menu Items should show a required field error

Update the menu Country item (no USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select a new country (no USA)
  5. The Country Item should show the selected Country
  6. The State Input should be an input component
  7. You can select new ones and the Menu Item should be updated

Update the menu Country item (USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select United State
  5. Should send you back and the Country Item should show the selected Country
  6. The State Input should be a Menu Item

Update the menu State item (USA)

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Click on Country item
  4. Should send you to a new page, select United State
  5. The Country Item should show the selected Country
  6. Clicking on the State menu should send you to a new Page
  7. You can select any State
  8. Should send you back to and show you the updated State

Autocomplete address

  1. Sign in using an User that doesn't have address
  2. Go to the Address Page (No inputs should be filled)
  3. Start filling the Address Line 1, a suggestion menu should shows up
  4. Clicking on any address should autocomplete, menu items and inputs
  • Verify you can update the Menu Items or you can go back to from the selection and the last selection should be in place
  • 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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
pushPage_safari.mp4
pusgPage_chrome.mp4
pushPage_safariError.mp4
Mobile Web - Chrome
pusgPage_chromeMobile.mp4
Mobile Web - Safari
pushPage_safariMobile.mp4
Desktop
pushPage_desktop.mp4
iOS
pushPage_ios.mp4
Android
pushPage_android.mp4

@MelvinBot
Copy link

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@@ -48,6 +48,10 @@ const propTypes = {
/** A callback function when the value of this field has changed */
onInputChange: PropTypes.func.isRequired,

onCountryChange: 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.

Add a comment explaining this function

@@ -48,6 +48,10 @@ const propTypes = {
/** A callback function when the value of this field has changed */
onInputChange: PropTypes.func.isRequired,

onCountryChange: PropTypes.func,

onStateChange: 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.

Same here


)}
<FormSpace />

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

maxLength={CONST.FORM_CHARACTER_LIMIT}
/>
<FormSpace />

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

</View>
<View style={styles.mb4}>
) : (

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

return _.filter(countries, country => country.text.toLowerCase().includes(searchValue.toLowerCase()));
}

function CountrySelectorPage(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

DRY, This file has a lot of similarities with the StateSelectorPage component. Could you consider refactoring this code to create more reusable components that can be shared across multiple files?

@@ -96,6 +96,14 @@ function getCountryISO(countryName) {
return _.findKey(CONST.ALL_COUNTRIES, country => country === countryName) || '';
}

function getCountryNameBy(countryISO) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
function getCountryNameBy(countryISO) {
/**
* Returns the name of the country associated with the provided ISO code.
* If the provided code is invalid, an empty string is returned.
*
* @param {string} countryISO The ISO code of the country to look up.
* @returns {string} The name of the country associated with the provided ISO code.
*/
function getCountryNameBy(countryISO) {

@@ -52,23 +52,41 @@ const defaultProps = {
},
};

function FormSpace() {
Copy link
Contributor

@ArekChr ArekChr May 5, 2023

Choose a reason for hiding this comment

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

Consider encapsulating FormSpace in the AddressPage, as it is only used in one component.
Or just use <View style={styles.formSpaceVertical} /> instead.

Navigation.navigate(ROUTES.getUsaStateSelectionRoute(stateTitle || stateISO, Navigation.getActiveRoute()));
}, [stateTitle, stateISO]);

const title = useMemo(() => {
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 memoization is not needed here

Copy link
Contributor

Choose a reason for hiding this comment

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

I propose to write a separate function for that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I move it into a function I will need to pass the props, and according to the guidelines I will wrap it into a useCallback so will look kind the same but will recalculate the same values so I would keep it into a memo given that other components can cause re-renders

Screen Shot 2023-05-05 at 16 55 33

Copy link
Contributor

@ArekChr ArekChr May 8, 2023

Choose a reason for hiding this comment

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

But this is a string type, which shouldn't cause a re-render in case the title stays the same without using useMemo, that because I requested removing that because it's a cheap function. and it is no matter of the render count

Comment on lines 41 to 42
const navigation = props.navigation;
const onInputChange = props.onInputChange;
const defaultValue = props.defaultValue;
const translate = props.translate;
Copy link
Contributor

Choose a reason for hiding this comment

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

Too many unnecessary declarations here, to improve readability please destruct props in component or call functions with just a simple approach props.navigation.navigate(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I talked internally about this but seems that we aren't gonna do destruction, but probably we can bring it back in discussion

Copy link
Contributor

Choose a reason for hiding this comment

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

This topic is mainly about defaultProps with destructing, but let's leave destructing until that is clarified.
I propose to use simple syntax props.navigation.navigate to reduce variable declaration, which will improve the hook's readability right now, it looks a bit messy

@ArekChr ArekChr mentioned this pull request May 5, 2023
55 tasks
@ArekChr
Copy link
Contributor

ArekChr commented May 8, 2023

Except for minor improvements that the guidelines are in the process of clarifying. Overall, LGTM 👌

@gedu gedu marked this pull request as ready for review May 8, 2023 13:54
@gedu gedu requested a review from a team as a code owner May 8, 2023 13:54
@melvin-bot melvin-bot bot requested review from cristipaval and mananjadhav and removed request for a team May 8, 2023 13:55
@melvin-bot
Copy link

melvin-bot bot commented May 8, 2023

@cristipaval @mananjadhav One of you needs to 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]

@gedu
Copy link
Contributor Author

gedu commented May 11, 2023

@best-lucky1030 No, is ready for Expensify review

@gedu
Copy link
Contributor Author

gedu commented May 16, 2023

@venture1981 all solved

@cristipaval
Copy link
Contributor

bump @mananjadhav

@mananjadhav
Copy link
Collaborator

Taking longer than expected, reviewed half the files, reviewing the other half and will test it as well.

@mananjadhav
Copy link
Collaborator

I reviewed and I am fine with the changes, but I see an outstanding comment on making it DRY - StateSelector and CountrySelector. Are we looking to fix this right now ? or follow up in another PR.

@cristipaval
Copy link
Contributor

cristipaval commented May 22, 2023

I just thought now that it would be great if @shawnborton has some time to review this from the design standpoint 🙏

@gedu
Copy link
Contributor Author

gedu commented May 22, 2023

@mananjadhav that change is done, both components are using OptionsSelectorWithSearch

@cristipaval cristipaval requested review from 0xmiros and removed request for mananjadhav May 24, 2023 17:30
Copy link
Contributor

@0xmiros 0xmiros left a comment

Choose a reason for hiding this comment

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

OptionsSelector already supports search. Why can't we reuse that component?
PronounsPage is a good example. I don't see major UI difference between country/state selector pages and pronouns page.
Also let's implement what pronouns page does:

  • pre-populate search input and auto-scroll to selected item
  • deselect support
  • trim search
bug1.mov

@0xmiros
Copy link
Contributor

0xmiros commented May 29, 2023

Hover background area is not familiar to me. Is this design approved? I'd expect to cover full width and enough vertical padding like other menu items.

bug2

@0xmiros
Copy link
Contributor

0xmiros commented May 29, 2023

I think we should still support shouldSaveDraft in Form.

bug3.mov

@0xmiros
Copy link
Contributor

0xmiros commented May 29, 2023

Show state name here, not code.

bug4.mov

@shawnborton
Copy link
Contributor

Hover background area is not familiar to me. Is this design approved? I'd expect to cover full width and enough vertical padding like other menu items.

I agree, that does not look great. I agree that the hover styles should match full width like places in the app.

@shawnborton
Copy link
Contributor

For these push-to-page rows, are we using a global component? I was surprised to see that the label font size is smaller when there is no value:
image

For that "emtpy state" of the push row when there is no value set, the font size should be 15px. Can we make sure that is the case for all of these rows, everywhere? cc @cristipaval

Then once a value is set, the label size goes to 13px and it rests above the value, which is at 15px.

@shawnborton
Copy link
Contributor

For the list selection views, @cristipaval where do we stand with updating the styles there? we shouldn't have the lines go edge-to-edge, and I thought we had an issue open to make sure the list selection is consistent everywhere.

image

@shawnborton
Copy link
Contributor

When the address dropdown/popover shows, why does that push the rest of the modal content down? I would think it would overlay on top of the content:
image

@shawnborton
Copy link
Contributor

It feels weird to me that state comes before City here:
image

@0xmiros
Copy link
Contributor

0xmiros commented May 29, 2023

When the address dropdown/popover shows, why does that push the rest of the modal content down? I would think it would overlay on top of the content

This is already happening on production. Maybe we can create a separate GH to handle that.

@gedu
Copy link
Contributor Author

gedu commented Jun 7, 2023

@cristipaval @0xmiroslav Conflicts solved


export {greenCheckmark};

export default withLocalize(CountrySelectorPage);
Copy link
Contributor

Choose a reason for hiding this comment

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

The component name is wrong. Should be aligned with file name.


const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success};

function filterOptions(searchValue, countries) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is general component, replace all specific names with general ones. i.e. countries -> data

Suggested change
function filterOptions(searchValue, countries) {
function filterOptions(searchValue, data) {

@0xmiros
Copy link
Contributor

0xmiros commented Jun 8, 2023

@gedu I noticed recent commits are not signed. All commits in the PR should be signed to pass checks.

@gedu gedu force-pushed the edu/17548_personal_details_push_to_page branch from a233ce1 to a13e904 Compare June 9, 2023 10:21
@gedu
Copy link
Contributor Author

gedu commented Jun 9, 2023

@0xmiroslav I'm having some issues trying to sign previous commits, I tried many commands also some shared into slack but no luck. can I create a new PR? what do you think?

@0xmiros
Copy link
Contributor

0xmiros commented Jun 9, 2023

@gedu we don't recommend force-push once review started but try only this time

@gedu
Copy link
Contributor Author

gedu commented Jun 9, 2023

@gedu we don't recommend force-push once review started but try only this time

@0xmiroslav what do you mean by a force-push? That won't sign the old commits, there are 3 commits that need to be signed, I could sign one of the last ones but those that are from May are getting hard

@0xmiros
Copy link
Contributor

0xmiros commented Jun 9, 2023

Maybe you can push all of work so far in one commit. You're about to do this in new PR, right?

@gedu
Copy link
Contributor Author

gedu commented Jun 9, 2023

Maybe you can push all of work so far in one commit. You're about to do this in new PR, right?

Yeah, I will create a new PR, because one of the unsigned commits is from May, and rebasing is really complicated

@0xmiros
Copy link
Contributor

0xmiros commented Jun 9, 2023

force-push doesn't require rebasing. You can do in this branch as if you do in a new branch
Maybe try this:

  • git checkout main
  • git branch -D edu/17548_personal_details_push_to_page (delete local branch)
  • git checkout -b gedu:edu/17548_personal_details_push_to_page (create new local branch)
  • commit your changes
  • git push -f (force push)

@0xmiros
Copy link
Contributor

0xmiros commented Jun 9, 2023

Wanna keep same PR just to have long convo history so far. i.e. important discussions about design

@gedu gedu force-pushed the edu/17548_personal_details_push_to_page branch from 8e925bc to 1cfa2ba Compare June 9, 2023 14:43
@gedu
Copy link
Contributor Author

gedu commented Jun 9, 2023

@0xmiroslav pushed, sorry for the inconvenience, my main Mac is broken so using my backup Mac I forgot to sign the commits

@gedu
Copy link
Contributor Author

gedu commented Jun 13, 2023

@0xmiroslav any updates?

@gedu
Copy link
Contributor Author

gedu commented Jun 15, 2023

@0xmiroslav is something that I can help with to get this PR to merge?

@0xmiros
Copy link
Contributor

0xmiros commented Jun 15, 2023

Sorry I will review this today. Please pull main.

@gedu gedu force-pushed the edu/17548_personal_details_push_to_page branch from 1c164df to b2e31bd Compare June 15, 2023 15:42
@0xmiros
Copy link
Contributor

0xmiros commented Jun 19, 2023

OptionsSelector already supports search. Why can't we reuse that component? PronounsPage is a good example. I don't see major UI difference between country/state selector pages and pronouns page. Also let's implement what pronouns page does:

  • pre-populate search input and auto-scroll to selected item
  • deselect support
  • trim search

bug1.mov

This was not addressed yet

@0xmiros
Copy link
Contributor

0xmiros commented Jun 19, 2023

BUG: weird transition animation (the entire page flickers)

bug1.mov

@0xmiros
Copy link
Contributor

0xmiros commented Jun 19, 2023

BUG: after saving state, country is reverted

bug2.mov

@0xmiros
Copy link
Contributor

0xmiros commented Jun 19, 2023

BUG: space between address line 1 and line 2 is bigger than others

bug3

@0xmiros
Copy link
Contributor

0xmiros commented Jun 19, 2023

BUG: after selecting address from auto-complete menu,

  • shows state required error even though it's already filled
  • error style broken
bug4.mov

@0xmiros
Copy link
Contributor

0xmiros commented Jun 19, 2023

@gedu please compare with staging and fix all differences other than push-to-page features.

@gedu
Copy link
Contributor Author

gedu commented Jun 19, 2023

@0xmiroslav

  • pre-populate search input and auto-scroll to selected item: FIXED
  • BUG: weird transition animation (the entire page flickers): New Nav bug, not related with this happens in other screens
  • BUG: after saving state, country is reverted: This happens in production, I would create another issue to solve this
  • BUG: space between address line 1 and line 2 is bigger than others: FIXED
  • BUG: after selecting address from auto-complete menu: FIXED
Screen Shot 2023-06-19 at 11 48 00
autocompleted_error.mp4

Navigation bug in another screen

nav_error_split_money.mp4

@gedu gedu force-pushed the edu/17548_personal_details_push_to_page branch from 64d43f0 to c3f057e Compare June 19, 2023 10:15
@gedu gedu closed this Jun 19, 2023
@gedu gedu force-pushed the edu/17548_personal_details_push_to_page branch from 71f9366 to b997868 Compare June 19, 2023 15:36
@gedu gedu mentioned this pull request Jun 19, 2023
58 tasks
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.

7 participants