diff options
| author | Benjamin Vray <bvr@odoo.com> | 2021-01-26 11:42:46 +0000 |
|---|---|---|
| committer | Benjamin Vray <bvr@odoo.com> | 2021-01-28 10:31:50 +0000 |
| commit | ad56d50e3da000cacdc70d9230cad308d03680bf (patch) | |
| tree | 4dd7bc44ecc50bc62f596ec8005183fc5c49f72a /addons/web_editor/static | |
| parent | ad0a0c573d05343e0ff3c99743680052c8676833 (diff) | |
[FIX] web_editor: fix dropzones with invisible element
Before this commit, dropzones were created around invisible elements
(e.g. the snippet popup). So we had 2 dropzones instead of one at some
locations.
After this commit, we avoid creating dropzones around elements that
must not have dropzones.
task-2312878
closes odoo/odoo#65198
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.editor.js | 16 |
1 files changed, 13 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 4e151f29546..3437ddf78ed 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1356,16 +1356,26 @@ var SnippetsMenu = Widget.extend({ $selectorSiblings = $(_.uniq(($selectorSiblings || $()).add($selectorChildren.children()).get())); } + var noDropZonesSelector = '[data-invisible="1"], .o_we_no_overlay, :not(:visible)'; if ($selectorSiblings) { - $selectorSiblings.not('.oe_drop_zone, .oe_drop_clone').each(function () { + $selectorSiblings.not(`.oe_drop_zone, .oe_drop_clone, ${noDropZonesSelector}`).each(function () { var data; var $zone = $(this); + var $zoneToCheck = $zone; - if (!$zone.prev('.oe_drop_zone:visible, .oe_drop_clone').length) { + while ($zoneToCheck.prev(noDropZonesSelector).length) { + $zoneToCheck = $zoneToCheck.prev(); + } + if (!$zoneToCheck.prev('.oe_drop_zone:visible, .oe_drop_clone').length) { data = setDropZoneDirection($zone, $zone.parent()); self._insertDropzone($('<we-hook/>').insertBefore($zone), data.vertical, data.style); } - if (!$zone.next('.oe_drop_zone:visible, .oe_drop_clone').length) { + + $zoneToCheck = $zone; + while ($zoneToCheck.next(noDropZonesSelector).length) { + $zoneToCheck = $zoneToCheck.next(); + } + if (!$zoneToCheck.next('.oe_drop_zone:visible, .oe_drop_clone').length) { data = setDropZoneDirection($zone, $zone.parent()); self._insertDropzone($('<we-hook/>').insertAfter($zone), data.vertical, data.style); } |
