Create a setup-autocomplete modifier & usage#450
Conversation
| state: '', | ||
| zipcode: '', | ||
| country: defaultCountry, | ||
| formattedAddress |
There was a problem hiding this comment.
The value is setup when the parseAddressComponents is called. It happens in handlePlaceChanged in the setup-autocomplete.ts
private handlePlaceChanged(place: GooglePlaceResult): void {
if (!place.address_components) return;
const formattedAddress = this.targetInput?.value ?? '';
this.result = parseAddressComponents(place.address_components, formattedAddress); // here
this.callback?.(this.result);
}The formatted address is the one generate by google map. When you click on a address, google map add the formatted value in the input value directly. So I need to have the input to get this value. This is why I don't do it in the address-parser directly
| formattedAddress | ||
| }; | ||
|
|
||
| const mapper: Record<AddressComponentType, (comp: GoogleAddressComponent) => void> = { |
There was a problem hiding this comment.
We are mapping all possible AddressComponentType yet AutocompletioinAddress is not using all of them ?
There was a problem hiding this comment.
The AddressComponentType is the type attribute returned by google map, the AutocompletioinAddress is the one we use on our side.
The is a example of what google returns
[
{
"long_name": "75013",
"short_name": "75013",
"types": [
"postal_code"
]
},
{
"long_name": "France",
"short_name": "FR",
"types": [
"country",
"political"
]
},
{
"long_name": "Île-de-France",
"short_name": "IDF",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "Paris",
"short_name": "Paris",
"types": [
"administrative_area_level_2",
"political"
]
},
{
"long_name": "Paris",
"short_name": "Paris",
"types": [
"locality",
"political"
]
},
{
"long_name": "Avenue d'Italie",
"short_name": "Av. d'Italie",
"types": [
"route"
]
},
{
"long_name": "69",
"short_name": "69",
"types": [
"street_number"
]
}
]| }); | ||
|
|
||
| module('Element setup', () => { | ||
| test('it works with a text input element directly', async function (assert) { |
There was a problem hiding this comment.
do we want to verify the error case you are raising in the modifier when the target elem is not an input ?
There was a problem hiding this comment.
I will add these missing test cases
There was a problem hiding this comment.
forgotten maybe ? can't see it :)
There was a problem hiding this comment.
It is the two test case handles missing input element gracefully & handles missing input element in its children gracefully
b77b22c to
fbf5619
Compare
455e991 to
7ab2d92
Compare
7ab2d92 to
b4bf65f
Compare
c4ba078
into
feature/payment-requests-onboarding-rework
What does this PR do?
Implements a reusable Ember modifier that integrates Google Places Autocomplete with input elements for address autocompletion. The modifier automatically wraps input elements in a container, handles Google Maps API loading, and parses place results into structured address data.
Key features:
address1,city,state,zipcode,country, andformattedAddressWhat are the observable changes?
Screencast.from.2026-01-26.11-59-50.webm
🧑💻 Developer Heads Up
⚡ Since we are using Ember Octane now:
Useful Resource : Ember Octane vs Classic Cheat Sheet
Good PR checklist