From 0783f7ca716ead66524e7e937a80dfc8f6712669 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Sat, 8 Oct 2022 19:06:23 +0000 Subject: [PATCH] [FIX] web: properly handle smooth drag and drop for iframe normal scroll The smooth drag and drop in edit mode (over the website iframe) currently works correctly. This would not be the case if the scroll was not on the `#wrapwrap` but left to the `` element. Indeed, special code handles that case, but that code is actually not needed in case what is being dragged is outside an iframe and that the smooth scrolling is performed inside that iframe. Note: a further commit will move back the scrollbar behavior out of the `#wrapwrap`, this is thus especially needed. X-original-commit: 4947ef118c646171fd3358135dcab8f63efa04d2 Part-of: odoo/odoo#102785 --- .../static/src/legacy/js/core/smooth_scroll_on_drag.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js b/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js index 1e9eeb20f6f..eb24875fe43 100644 --- a/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js +++ b/addons/web/static/src/legacy/js/core/smooth_scroll_on_drag.js @@ -262,9 +262,12 @@ const SmoothScrollOnDrag = Class.extend(mixins.ParentedMixin, { visibleOffset.right += x; } - // If this.$scrollTarget is the html tag, we need to take the scroll position in to account - // as offsets positions are calculated relative to the document (thus ). - if (this.scrollTargetIsDocument) { + // If this.$scrollTarget is the html tag, we need to take the scroll + // position into account as offsets positions are calculated relative to + // the document (thus ). Except in the case where what is being + // dragged is out of an iframe and that the scrolling is being done + // inside that iframe. + if (this.scrollTargetIsDocument && !this.iframeOffset) { const scrollTargetScrollTop = this.$scrollTarget.scrollTop(); const scrollTargetScrollLeft = this.$scrollTarget.scrollLeft(); visibleOffset.top -= scrollTargetScrollTop;