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

Add better support for non-US cities in address autocomplete by pulling in postal_town #16567

Merged
merged 3 commits into from
Mar 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 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: locality,
sublocality: sublocality,
postal_town: postalTown,
jjcoffee marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -130,7 +132,10 @@ const AddressSearch = (props) => {

const values = {
street: props.value ? props.value.trim() : '',
city: city || cityFallback,
// When locality is not returned, many (non-US) countries return the city as
// postalTown, otherwise as sublocality. If postalTown is returned, the
// sublocality will be a city subdivision so wouldn't be appropriate.
jjcoffee marked this conversation as resolved.
Show resolved Hide resolved
city: locality || postalTown || sublocality,
zipCode,
state,
country: '',
Expand Down