diff options
| author | Benjamin Vray <bvr@odoo.com> | 2020-11-20 14:01:50 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2021-01-27 14:57:48 +0000 |
| commit | edf28efe19bedfe5eb62baf6fa5832a50d18e775 (patch) | |
| tree | d9a14cd89d7a0cced1e95330409b5944c971b13b /addons/web_editor/static/src | |
| parent | a67f7df31a9e5a5550d54d52ae506299f4a62581 (diff) | |
[FIX] web_editor: fix scroll during dragging a snippet in a modal
Before this commit, it was not possible to scroll a popup with a
dragged snippet.
Part of https://github.com/odoo/odoo/pull/61998
task-2312878
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.editor.js | 17 |
1 files changed, 13 insertions, 4 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 0ebf68345e1..a67f45b3dc0 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -666,9 +666,14 @@ var SnippetEditor = Widget.extend({ } }, }); + + // If a modal is open, the scroll target must be that modal + const $openModal = self.$editable.find('.modal:visible'); + self.draggableComponent.$scrollTarget = $openModal.length ? $openModal : self.$scrollingElement; + // Trigger a scroll on the draggable element so that jQuery updates // the position of the drop zones. - this.$scrollingElement.on('scroll.scrolling_element', function () { + self.draggableComponent.$scrollTarget.on('scroll.scrolling_element', function () { self.$el.trigger('scroll'); }); }, @@ -731,7 +736,7 @@ var SnippetEditor = Widget.extend({ this.trigger_up('drag_and_drop_stop', { $snippet: this.$target, }); - this.$scrollingElement.off('scroll.scrolling_element'); + this.draggableComponent.$scrollTarget.off('scroll.scrolling_element'); }, /** * @private @@ -2015,9 +2020,13 @@ var SnippetsMenu = Widget.extend({ }, }); + // If a modal is open, the scroll target must be that modal + const $openModal = self.getEditableArea().find('.modal:visible'); + self.draggableComponent.$scrollTarget = $openModal.length ? $openModal : $scrollingElement; + // Trigger a scroll on the draggable element so that jQuery updates // the position of the drop zones. - $scrollingElement.on('scroll.scrolling_element', function () { + self.draggableComponent.$scrollTarget.on('scroll.scrolling_element', function () { self.$el.trigger('scroll'); }); @@ -2026,7 +2035,7 @@ var SnippetsMenu = Widget.extend({ }, stop: async function (ev, ui) { $toInsert.removeClass('oe_snippet_body'); - $scrollingElement.off('scroll.scrolling_element'); + self.draggableComponent.$scrollTarget.off('scroll.scrolling_element'); if (!dropped && ui.position.top > 3 && ui.position.left + ui.helper.outerHeight() < self.el.getBoundingClientRect().left) { var $el = $.nearest({x: ui.position.left, y: ui.position.top}, '.oe_drop_zone', {container: document.body}).first(); |
