Skip to content

Commit

Permalink
Merge pull request #16567 from jjcoffee/16392
Browse files Browse the repository at this point in the history
Add better support for non-US cities in address autocomplete by pulling in postal_town
  • Loading branch information
aldo-expensify authored Mar 28, 2023
2 parents 752ac61 + a4c943a commit 3a9ce6f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/AddressSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ const AddressSearch = (props) => {
const {
street_number: streetNumber,
route: streetName,
locality: city,
sublocality: cityFallback, // Some locations only return sublocality instead of locality
locality,
sublocality,
postal_town: postalTown,
postal_code: zipCode,
administrative_area_level_1: state,
country,
Expand All @@ -115,6 +116,7 @@ const AddressSearch = (props) => {
route: 'long_name',
locality: 'long_name',
sublocality: 'long_name',
postal_town: 'long_name',
postal_code: 'long_name',
administrative_area_level_1: 'short_name',
country: 'short_name',
Expand All @@ -132,7 +134,12 @@ const AddressSearch = (props) => {
// Refer to https://github.com/Expensify/App/issues/15633 for more information.
const values = {
street: props.value ? props.value.trim() : '',
city: city || cityFallback,

// When locality is not returned, many countries return the city as postalTown (e.g. 5 New Street
// Square, London), otherwise as sublocality (e.g. 384 Court Street Brooklyn). If postalTown is
// returned, the sublocality will be a city subdivision so shouldn't take precedence (e.g.
// Salagatan, Upssala, Sweden).
city: locality || postalTown || sublocality,
zipCode,
country: '',
state,
Expand Down

0 comments on commit 3a9ce6f

Please sign in to comment.