From 2a70b21af3036d971f65409d565a8633dbbbaf81 Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Mon, 18 Oct 2021 09:28:38 +0000 Subject: [PATCH] [FIX] web_editor: display drop zones only on dropdowns when shown It was painful to add an inline snippets, or move elements inside mega menus. The dropdowns are now behaving as modals: if they are shown, the user can only add or move snippets inside them, but not outside. task-2668908 closes odoo/odoo#80757 X-original-commit: edc5c8d69fb5fc6da0b0012abc6539c21ffc421e Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/editor/snippets.editor.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 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 604113d2d1a..9e6e4b81d07 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1568,11 +1568,16 @@ var SnippetsMenu = Widget.extend({ _activateInsertionZones: function ($selectorSiblings, $selectorChildren) { var self = this; - // If a modal is open, the drop zones must be created only in this modal - const $openModal = self.getEditableArea().find('.modal:visible'); - if ($openModal.length) { - $selectorSiblings = $openModal.find($selectorSiblings); - $selectorChildren = $openModal.find($selectorChildren); + // If a modal or a dropdown is open, the drop zones must be created + // only in this element. + const $editableArea = self.getEditableArea(); + let $open = $editableArea.find('.modal:visible'); + if (!$open.length) { + $open = $editableArea.find('.dropdown-menu.show').addBack('.dropdown-menu.show').parent(); + } + if ($open.length) { + $selectorSiblings = $open.find($selectorSiblings); + $selectorChildren = $open.find($selectorChildren); } // Check if the drop zone should be horizontal or vertical