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

HS-1272111 Add Address Auto-Fill bug #1230

Merged
merged 1 commit into from
Dec 19, 2024
Merged

Conversation

caleballdrin
Copy link
Contributor

@caleballdrin caleballdrin commented Dec 17, 2024

Description

https://secure.helpscout.net/conversation/2787902057/1272111?viewId=7669074

  • Keep formik in sync by setting the street to the full description before changing it back

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@caleballdrin caleballdrin self-assigned this Dec 17, 2024
@caleballdrin caleballdrin requested a review from canac December 17, 2024 22:50
@caleballdrin caleballdrin added the Preview Environment Add this label to create an Amplify Preview label Dec 17, 2024
Copy link
Contributor

Preview branch generated at https://HS1272111-address-autofill.d3dytjb8adxkk5.amplifyapp.com

Copy link
Contributor

github-actions bot commented Dec 17, 2024

Bundle sizes [mpdx-react]

Compared against 7e667dd

No significant changes found

@caleballdrin caleballdrin changed the title Add setTimeout to wait for formik to set the fields HS-1272111 Add Address Auto-Fill bug Dec 17, 2024
@canac
Copy link
Contributor

canac commented Dec 18, 2024

Code looks good! I'll test it when I'm back at my desk. Can you add a code comment explaining why we need the setTimeout?

@canac
Copy link
Contributor

canac commented Dec 18, 2024

Do we need the same logic in EditContactAddressModal and CreateMultipleContacts?

@canac
Copy link
Contributor

canac commented Dec 18, 2024

I think it works if you remove the timeout and change the onChange handler for the Autocomplete in StreetAutoComplete to

onChange={(_event, newValue) => {
  if (typeof newValue === 'string') {
    onStreetChange(newValue);
  } else {
    onStreetChange(newValue.description); // add this line
    handlePlaceChosen(newValue);
  }
}}

The problem was that the autocomplete's text was getting out of sync with Formik. Adding the extra onStreetChange sets the Formik street to the full address so that onPredictionChosen can then set it to just the street.

Can you try that and let me know if it works for you in your testing?

@caleballdrin
Copy link
Contributor Author

@canac that works! good catch!

@caleballdrin caleballdrin force-pushed the HS1272111-address-autofill branch from f3851a4 to e830e24 Compare December 19, 2024 02:37
@caleballdrin caleballdrin merged commit 9ce4dca into main Dec 19, 2024
19 checks passed
@caleballdrin caleballdrin deleted the HS1272111-address-autofill branch December 19, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Preview Environment Add this label to create an Amplify Preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants