[FIX] website: make address selection in editor more robust

Using the "gps picker" (for example with the "Google Map" snippet) was
not flawless. The autocomplete menu which shows up when the user enters
an address is handled by the gmap API. It was actually not working at
all on Firefox for an unknown reason. Not listening to blur events on
the input seems to solve the issue. This commit also prevents triggering
a value change if the same address is reselected which seems to make
address changes a bit more robust too.

opw-2976261

X-original-commit: 50bf0b7f1677b8125d892fad968ccc8174c974c1
Part-of: odoo/odoo#106103
This commit is contained in:
qsm-odoo
2022-11-21 21:18:58 +01:00
parent 5c51f6c4f3
commit 2b640b2c2a
@@ -304,9 +304,11 @@ const FontFamilyPickerUserValueWidget = SelectUserValueWidget.extend({
});
const GPSPicker = InputUserValueWidget.extend({
events: { // Explicitely not consider all InputUserValueWidget events
'blur input': '_onInputBlur',
},
// Explicitly not consider all InputUserValueWidget events. E.g. we actually
// don't want input focusout messing with the google map API. Because of
// this, clicking on google map autocomplete suggestion on Firefox was not
// working properly.
events: {},
/**
* @constructor
@@ -483,9 +485,12 @@ const GPSPicker = InputUserValueWidget.extend({
if (gmapPlace && gmapPlace.geometry) {
this._gmapPlace = gmapPlace;
const location = this._gmapPlace.geometry.location;
const oldValue = this._value;
this._value = `(${location.lat()},${location.lng()})`;
this._gmapCacheGPSToPlace[this._value] = gmapPlace;
this._onUserValueChange(ev);
if (oldValue !== this._value) {
this._onUserValueChange(ev);
}
}
},
});