From 2b640b2c2a3add8fc177591459aa2d082dcdde7d Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 4 Nov 2022 13:25:47 +0000 Subject: [PATCH] [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 --- .../static/src/js/editor/snippets.options.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 8a5e508a86a..341be487ff6 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -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); + } } }, });