Skip to content

Commit

Permalink
[FIX] web_editor: fix dropzones with invisible element
Browse files Browse the repository at this point in the history
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#65230

X-original-commit: ad56d50
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
  • Loading branch information
bvr-odoo authored and qsm-odoo committed Jan 28, 2021
1 parent 6e10362 commit f9bd303
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions addons/web_editor/static/src/js/editor/snippets.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1351,16 +1351,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);
}
Expand Down

0 comments on commit f9bd303

Please sign in to comment.