From 116afad9fa2aaa5131b17988c05fedceb7f1dd51 Mon Sep 17 00:00:00 2001 From: Younn Olivier Date: Fri, 22 Oct 2021 10:49:05 +0000 Subject: [PATCH] [FIX] web_editor: correctly move snippets on a popup Inside a scrollable popup, the scroll was not correctly triggered when moving one of its snippets through drag and drop. This commit correctly defines the SmoothScrollOnDrag.$scrollTarget when a modal is shown. task-2431469 closes odoo/odoo#82040 X-original-commit: 844051168311ac0c3e8640dda2a90545e373c98d Signed-off-by: Quentin Smetz (qsm) Co-authored-by: qsm-odoo --- .../web_editor/static/src/js/editor/snippets.editor.js | 10 +++------- 1 file changed, 3 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 13eb6842625..13e73730e41 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -214,7 +214,9 @@ var SnippetEditor = Widget.extend({ }, }, }); - const $scrollable = (this.options.wysiwyg.snippetsMenu && this.options.wysiwyg.snippetsMenu.$scrollable) + const modalAncestorEl = this.$target[0].closest('.modal'); + const $scrollable = modalAncestorEl && $(modalAncestorEl) + || (this.options.wysiwyg.snippetsMenu && this.options.wysiwyg.snippetsMenu.$scrollable) || (this.$scrollingElement.length && this.$scrollingElement) || $().getScrollingElement(this.ownerDocument); this.draggableComponent = new SmoothScrollOnDrag(this, this.$el, $scrollable, smoothScrollOptions); @@ -905,12 +907,6 @@ var SnippetEditor = Widget.extend({ }, }); - // If a modal is open, the scroll target must be that modal - const $openModal = self.$editable.find('.modal:visible'); - if ($openModal.length) { - self.draggableComponent.$scrollTarget = $openModal; - } - // Trigger a scroll on the draggable element so that jQuery updates // the position of the drop zones. self.draggableComponent.$scrollTarget.on('scroll.scrolling_element', function () {