summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src
diff options
context:
space:
mode:
authorBenjamin Vray <bvr@odoo.com>2021-02-15 10:22:03 +0000
committerBenjamin Vray <bvr@odoo.com>2021-02-16 09:18:13 +0000
commit66b468626e046a13a463cff3a2285801016f3ed7 (patch)
treea16964b549baf35f12559b458ad7b06f8cbddb86 /addons/web_editor/static/src
parent73d82d411ca62c284b3364b9a76c1001fe9e44e9 (diff)
[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#66165 X-original-commit: 3ac79957d8f6948c965f76e0b5d73ba39a34c69e Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static/src')
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.editor.js19
1 files changed, 12 insertions, 7 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 3997e6df15c..57721dd1e87 100644
--- a/addons/web_editor/static/src/js/editor/snippets.editor.js
+++ b/addons/web_editor/static/src/js/editor/snippets.editor.js
@@ -660,10 +660,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();
@@ -2027,11 +2029,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();