From 82711f772a6b0fc615e32a6b0faaba0e38184ead Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Fri, 24 Sep 2021 19:57:29 +0000 Subject: [PATCH] [FIX] web_editor: properly drop to nearest in iframe The feature to drop snippets to the nearest allowed position was broken in iframes because of a reference to a JQuery contained in a different document than the editable area. This restores the feature in all cases. task-2554899 X-original-commit: 4be474283f7fb6abbea8707d346f0d71939efce2 Part-of: odoo/odoo#77724 --- addons/web_editor/static/src/js/editor/snippets.editor.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 638f93e442a..75606cf5f16 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -2381,14 +2381,15 @@ var SnippetsMenu = Widget.extend({ self._mutex.exec(() => prom); }, stop: async function (ev, ui) { + const doc = self.options.wysiwyg.odooEditor.document; self.options.wysiwyg.odooEditor.automaticStepUnactive(); self.options.wysiwyg.odooEditor.automaticStepSkipStack(); $toInsert.removeClass('oe_snippet_body'); self.draggableComponent.$scrollTarget.off('scroll.scrolling_element'); if (!dropped && ui.position.top > 3 && ui.position.left + ui.helper.outerHeight() < self.el.getBoundingClientRect().left) { const point = {x: ui.position.left, y: ui.position.top}; - const container = {container: document.body}; - let droppedOnNotNearest = $.touching( + const container = {container: doc.body}; + let droppedOnNotNearest = doc.defaultView.$.touching( point, '.oe_structure_not_nearest', container ).first(); // If dropped outside of a dropzone with class oe_structure_not_nearest, @@ -2396,7 +2397,7 @@ var SnippetsMenu = Widget.extend({ const selector = droppedOnNotNearest.length ? '.oe_drop_zone' : ':not(.oe_structure_not_nearest) > .oe_drop_zone'; - let $el = $.nearest( + let $el = doc.defaultView.$.nearest( point, selector, container ).first(); if ($el.length) {