Skip to content
Snippets Groups Projects
Commit 34b8c2e0 authored by Benjamin Vray's avatar Benjamin Vray
Browse files

[FIX] website: fix map snippet saved

This commit fixes the issue of having duplicate iframes when dropping a
custom "s_map" snippet that has been saved by the user.

This issue was introduced by this commit [1].

Steps to reproduce the bug:
- Drag and drop a "s_map" snippet onto the page.
- Save this "s_map" snippet by clicking on the custom snippet "save"
button.
- Drag and drop the saved snippet onto the page.
- Observe that a duplicate iframe is created in the snippet.

This commit adds a check to verify if an iframe already exists before
adding it when dropping a "s_map" snippet.

[1]: https://github.com/odoo/odoo/commit/88194dd94182ad1bbdcb9aa8f855f30f6369d148



task-3340644

closes odoo/odoo#122645

Signed-off-by: default avatarRomain Derie (rde) <rde@odoo.com>
parent 68b76c2f
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,15 @@ options.registry.Map = options.Class.extend({
* @override
*/
onBuilt() {
const iframeEl = generateGMapIframe();
this.$target[0].querySelector('.s_map_color_filter').before(iframeEl);
this._updateSource();
// The iframe is added here to the snippet when it is dropped onto the
// page. However, in the case where a custom snippet saved by the user
// is dropped, the iframe already exists and doesn't need to be added
// again.
if (!this.$target[0].querySelector('.s_map_embedded')) {
const iframeEl = generateGMapIframe();
this.$target[0].querySelector('.s_map_color_filter').before(iframeEl);
this._updateSource();
}
},
//--------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment