-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Only accept "address" result from google API - validate address_components before using it #5854
Conversation
|
…esssearch (cherry picked from commit b83d213)
🚀 Cherry-picked to staging by @roryabraham in version: 1.1.7-22 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by @AndrewGable in version: 1.1.7-24 🚀
|
🚀 Deployed to staging by @roryabraham in version: 1.1.7-25 🚀
|
🚀 Deployed to production by @roryabraham in version: 1.1.8-9 🚀
|
Details
We were getting results that were not full addresses from the google places API. An example of this is a "premise" type of result, which has the street name and number missing. i.e. search "88 Kearney Street", there are results that will cause the bug.
Adding this new parameter will prevent us from getting this kind of result and we only get full addresses:
https://developers.google.com/maps/documentation/places/web-service/supported_types#table3
As @roryabraham pointed up here (great catch!): #5840 (comment), it is not enough to add
types: 'address'
. Using this we can still get results that are 'routes', which don't have a street number.To fix this, I added the function
validateAddressComponents
to verify theaddress_components
checking point (2) and (3) in @roryabraham 's suggestions #5840 (comment) (thanks again 😝 )If we
validateAddressComponents
we nullify the valuesaddressStreet
,addressCity
,addressState
,addressZipCode
so our form regular validations will trigger on submit. If we don't nullify, we would keep the old values while showing the user something different in the UI.I didn't try to set any error from the
AddressSearch
because our approach so far has been that the form validation and setting errors is a responsibility of the form and not the individual input components.I think it is acceptable to do this verification here as it can be analog to verifying the format of a date in a date input. If the date format is totally wrong, the date input component would reject the date and call on change with undefined or null.
Fixed Issues
$ #5840
Tests / QA
because the selected result is missing the street number.
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android