[FIX] web_editor: fix drag and drop when drop zones are too close

Before this commit, the preview of the dragged snippet didn't work
when moving a dragged snippet from a drop zone to an other drop zone
when there was no space between those drop zones.

It is because, in this case, the over event of the second drop zone is
triggered before the out event of the first drop zone.

task-2312878

closes odoo/odoo#66267

X-original-commit: 66b468626e046a13a463cff3a2285801016f3ed7
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Benjamin Vray
2021-02-16 13:30:12 +00:00
parent 0e83fb5493
commit fed5854e32
@@ -668,10 +668,12 @@ var SnippetEditor = Widget.extend({
this.$editable.find('.oe_drop_zone').droppable({
over: function () {
if (!self.dropped) {
self.dropped = true;
$(this).first().after(self.$target).addClass('invisible');
if (self.dropped) {
self.$target.detach();
$('.oe_drop_zone').removeClass('invisible');
}
self.dropped = true;
$(this).first().after(self.$target).addClass('invisible');
},
out: function () {
var prev = self.$target.prev();
@@ -2025,11 +2027,14 @@ var SnippetsMenu = Widget.extend({
self.getEditableArea().find('.oe_drop_zone').droppable({
over: function () {
if (!dropped) {
dropped = true;
$(this).first().after($toInsert).addClass('invisible');
$toInsert.removeClass('oe_snippet_body');
if (dropped) {
$toInsert.detach();
$toInsert.addClass('oe_snippet_body');
$('.oe_drop_zone').removeClass('invisible');
}
dropped = true;
$(this).first().after($toInsert).addClass('invisible');
$toInsert.removeClass('oe_snippet_body');
},
out: function () {
var prev = $toInsert.prev();