From f2ea69a8cfab11f8537bc843b8a68555cae22707 Mon Sep 17 00:00:00 2001 From: "Louis (loco)" Date: Tue, 26 Sep 2023 10:52:04 +0200 Subject: [PATCH] [FIX] web_editor: show dropzones at an over after an over event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: - Add a "Text-Image" snippet on the website page. - Take an "Inner content" snippet from the right panel and drag it from a dropzone to another. It has to be fast so that the order of the "over" and "out" dropzone events is "over" > "over" > "out" and not "over" > "out" > "over" as usual. -> The exited dropzone is not correctly displayed. The problem is that since [1], the website is inside of an iframe. Due to that, the snippets menu does not have a direct access to the dropzones. To solve the problem, the already defined `$dropZones` variable is used instead of searching the dropzones inside the DOM. For the snippet editor, the problematic line has been deleted at it is already handled by `_outPreviousDropzone()`. This is acceptable since the commit that introduced `_outPreviousDropzone()` ([2]) and the commit that introduced the removed line ([3]) were both introduced to handle the case of an "over" after an "over". In other words, as `self.droppped` will always be `true` when `self.dragState.currentDropzoneEl` is set and it will always be `false` when `self.dragState.currentDropzoneEl` is not set, the problematic line can be removed as it is already handled in `outPreviousDropzone()`. [1]: https://github.com/odoo/odoo/commit/31cc10b [2]: https://github.com/odoo/odoo/commit/c6886410603a16b6a3c5fe459d273dd883c110c7 [3]: https://github.com/odoo/odoo/commit/fed5854e32bcddf8b14b8311b2fe542eed990f77 task-3522552 closes odoo/odoo#137255 X-original-commit: 06fde42d3ba0e8be2128cda8e695c5def917f391 Signed-off-by: Benjamin Vray (bvr) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 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 4f698d6839c..b0e8e318f7b 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1113,7 +1113,6 @@ var SnippetEditor = Widget.extend({ over: function () { if (self.dropped) { self.$target.detach(); - $('.oe_drop_zone').removeClass('invisible'); } // Prevent a column to be trapped in an upper grid dropzone at @@ -3283,7 +3282,8 @@ var SnippetsMenu = Widget.extend({ if (dropped) { $toInsert.detach(); $toInsert.addClass('oe_snippet_body'); - $('.oe_drop_zone').removeClass('invisible'); + [...$dropZones].forEach(dropzoneEl => + dropzoneEl.classList.remove("invisible")); } dropped = true; $(this).first().after($toInsert).addClass('invisible');