Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.32k stars 2.75k forks source link

[$250] Address - Address without state can be saved #47616

Open IuliiaHerets opened 3 weeks ago

IuliiaHerets commented 3 weeks ago

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


Version Number: v9.0.21-3 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to Account settings > Profile > Address.
  3. Select a US address.
  4. Click Country and select United Kingdom.
  5. Enter anything in State field and click Save (ignore the incorrect zip code).
  6. Click Country and select United States.
  7. Without selecting State, click Save.

Expected Result:

App should not be able to save address without state.

Actual Result:

The address without state can be saved

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

https://github.com/user-attachments/assets/2fc23309-2495-4397-a590-6b731ed8d501

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0142ffeec763fcd562
  • Upwork Job ID: 1828601412039191657
  • Last Price Increase: 2024-08-28
  • Automatic offers:
    • abzokhattab | Contributor | 103745348
Issue OwnerCurrent Issue Owner: @aimane-chnaif
melvin-bot[bot] commented 3 weeks ago

Triggered auto assignment to @anmurali (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

IuliiaHerets commented 3 weeks ago

We think that this bug might be related to #wave-collect - Release 1

IuliiaHerets commented 3 weeks ago

@anmurali FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

abzokhattab commented 3 weeks ago

Edited by proposal-police: This proposal was edited at 2024-08-18 22:28:21 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Address without state can be saved

What is the root cause of that problem?

The defaultValue prop is used in the state component of the AddressForm instead of value. As a result, when the value of the country changes, the state resets to "" here, but this change isn't reflected in the UI because defaultValue only sets the initial value. https://github.com/Expensify/App/blob/5a2602c441170093e99850e2194808218b0aa838/src/components/AddressForm.tsx#L191-L199

What changes do you think we should make in order to solve the problem?

We should use value instead of defaultValue in the StatePicker component, and adjust other components if necessary.

POC

https://github.com/user-attachments/assets/8241cf43-16d0-4117-b22e-c438911d5aea

wildan-m commented 3 weeks ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Address without state can still be saved.

What is the root cause of that problem?

We don't use defaultValue when we validate the form

What changes do you think we should make in order to solve the problem?

We can add shouldUseDefaultValue here:

https://github.com/Expensify/App/blob/62722e8bc636f1be2e2c9e8e980aac93b76804c9/src/components/AddressForm.tsx#L192-L198

What alternative solutions did you explore? (Optional)

N/A

melvin-bot[bot] commented 2 weeks ago

@anmurali Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] commented 2 weeks ago

@anmurali Still overdue 6 days?! Let's take care of this!

melvin-bot[bot] commented 2 weeks ago

Job added to Upwork: https://www.upwork.com/jobs/~0142ffeec763fcd562

melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @aimane-chnaif (External)

brad-isbell commented 2 weeks ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Address without state can be saved

What is the root cause of that problem?

using defaultValue instead of value causes the state InputWrapper component here to not rerender when the state variable changes.

What changes do you think we should make in order to solve the problem?

we should change defaultValue to value and pass the state variable. I also made some adjustments here so that we use only one component instead of two when the county is USA or any other country.

            <View style={isUSAForm ? styles.mhn5 : {}}>
                <InputWrapper
                    InputComponent={isUSAForm ? StateSelector : TextInput}
                    inputID={INPUT_IDS.STATE}
                    label={translate('common.stateOrProvince')}
                    aria-label={translate('common.stateOrProvince')}
                    role={isUSAForm ? CONST.ROLE.PRESENTATION : undefined}
                    value={state}
                    maxLength={isUSAForm ? CONST.FORM_CHARACTER_LIMIT : undefined}
                    spellCheck={!isUSAForm}
                    onValueChange={onAddressChanged}
                    shouldSaveDraft={shouldSaveDraft}
                />
            </View>

What alternative solutions did you explore? (Optional)

Result: https://github.com/user-attachments/assets/a5a644e8-c0f5-4898-a2e2-d2d2e0c54456

melvin-bot[bot] commented 2 weeks ago

πŸ“£ @brad-isbell! πŸ“£ Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
brad-isbell commented 2 weeks ago

Contributor details Your Expensify account email: mohamediyedrhimita@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~01e11da7d5ef514a1c

melvin-bot[bot] commented 2 weeks ago

βœ… Contributor details stored successfully. Thank you for contributing to Expensify!

aimane-chnaif commented 1 week ago

@abzokhattab's proposal looks good to me. It's weird that defaultValue is passed in state selector, while value is passed in country selector in current codebase. πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

shouldUseDefaultValue can be alternative option but I prefer using value since it's consistent with country selector. I see that @wildan-m raised discussion on slack but no one responded. I bumped in channel.

melvin-bot[bot] commented 1 week ago

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

melvin-bot[bot] commented 1 week ago

πŸ“£ @abzokhattab πŸŽ‰ An offer has been automatically sent to your Upwork account for the Contributor role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Keep in mind: Code of Conduct | Contributing πŸ“–

melvin-bot[bot] commented 1 week ago

@anmurali @techievivek @abzokhattab @aimane-chnaif this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

aimane-chnaif commented 1 week ago

Waiting for PR

abzokhattab commented 1 week ago

PR is Ready