Skip to content

Fix - Cannot enter address in personal details, address disappears after entering #28474 #30819

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

Merged
merged 16 commits into from
Nov 14, 2023
Merged
Changes from all commits
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: 11 additions & 0 deletions src/components/AddressSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ function AddressSearch(props) {
values.state = stateFallback;
}

// Some edge-case addresses may lack both street_number and route in the API response, resulting in an empty "values.street"
// We are setting up a fallback to ensure "values.street" is populated with a relevant value
if (!values.street && details.adr_address) {
const streetAddressRegex = /<span class="street-address">([^<]*)<\/span>/;
const adr_address = details.adr_address.match(streetAddressRegex);
const streetAddressFallback = lodashGet(adr_address, [1], null);
if (streetAddressFallback) {
values.street = streetAddressFallback;
}
}

// Not all pages define the Address Line 2 field, so in that case we append any additional address details
// (e.g. Apt #) to Address Line 1
if (subpremise && typeof props.renamedInputKeys.street2 === 'undefined') {
Expand Down