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.59k stars 2.93k forks source link

Address autofill is not giving correct suggestions based on country in the user personal details settings #25736

Closed m-natarajan closed 1 year ago

m-natarajan commented 1 year 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!


Action Performed:

  1. Go to settings -> profile -> personal details -> address
  2. Select a country from the country field
  3. In the address line 1 field, search a city/location of the country you selected.
  4. Notice the autofill suggestion, contains other countries location
  5. Repeat steps 2-3 with a different country, again verify step 4,

    Expected Result:

    If a user has a selected country, the autofill show only show locations from that country, and if the user has no selected country, the autofill should show suggestions from all locations.

    Actual Result:

    The autofill shows suggestions from all locations, instead of the selected country

    Workaround:

    Unknown

    Platforms:

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

    • [ ] Android / native
    • [ ] Android / Chrome
    • [ ] iOS / native
    • [ ] iOS / Safari
    • [x] MacOS / Chrome / Safari
    • [ ] MacOS / Desktop

Version Number: 1.3.56-14 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/38435837/2e781838-850a-4d95-9834-2d48e6a977dd

https://github.com/Expensify/App/assets/38435837/8891c595-572d-4432-85e1-a67e6f718355

Expensify/Expensify Issue URL: Issue reported by: @huzaifa-99 Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692011103310569

View all open jobs on GitHub

melvin-bot[bot] commented 1 year ago

Triggered auto assignment to @kevinksullivan (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

huzaifa-99 commented 1 year ago

Proposal

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

We want to show correct suggestions in the address field based on the user's selected country, instead of showing from all countries

What is the root cause of that problem?

In the AddressPage, we pass isLimitedToUSA={false}, which then makes the components key in query as undefiend here, which then shows all matching suggestions from all countries instead of the just the selected country

<AddressSearch/> uses google places autocomplete to show autofill suggestion

https://github.com/Expensify/App/blob/dd0d98fa6868bba60e81bfdf66e5cdf7d2adaa37/src/components/AddressSearch/index.js#L97-L104.

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

We should update the search query in <AddressSearch/> based on the user's selected country.

So instead of using isLimitedToUSA prop <AddressSearch/>, I suggest we use a countryISO prop with a default value of 'US', and update the query to be something like this

// pseudocode
const query = useMemo(
    () => ({
        language: props.preferredLocale,
        types: 'address',
        components: props.countryISO ? `country:${props.countryISO}` : undefined,
    }),
    [props.preferredLocale, props.countryISO],
);

and from the <AddressPage/> we pass countryISO={currentCountry} to <AddressSearch/> which would give relevant autofill suggestions.

In case if a user has no selected country, we can pass countryISO={null} // or undefined which would suggest search results from all locations/countries.

What alternative solutions did you explore? (Optional)

N/A

kevinksullivan commented 1 year ago

I think this is a new feature. Asking here

https://expensify.slack.com/archives/C049HHMV9SM/p1692916644511909?thread_ts=1692011103.310569&cid=C049HHMV9SM

kevinksullivan commented 1 year ago

not a bug, it's a new feature