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 () {