Skip to content

Commit 1c1af79

Browse files
thjo-odooabd-msyukyu-odoo
authored andcommitted
[FIX] fixed the scroll offset
1 parent 0366fb2 commit 1c1af79

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

addons/html_builder/static/src/sidebar/block_tab.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export class BlockTab extends Component {
218218
el: this.blockTabRef.el,
219219
elements: ".o_snippet.o_draggable",
220220
scrollingElement,
221+
externalScroll: () => Boolean(this.props.getExternalScrollableAncestor?.()),
221222
handle: ".o_snippet_thumbnail:not(.o_we_ongoing_insertion .o_snippet_thumbnail)",
222223
dropzones: () => dropzoneEls,
223224
helper: ({ element, helperOffset }) => {

addons/html_editor/static/src/utils/drag_and_drop.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const dragAndDropHookParams = {
102102
scrollingElement: [Function],
103103
helper: [Function],
104104
extraWindow: [Object, Function],
105+
externalScroll: [Function],
105106
},
106107
edgeScrolling: { enabled: true },
107108
onComputeParams({ ctx, params }) {
@@ -110,10 +111,18 @@ const dragAndDropHookParams = {
110111
ctx.getScrollingElement = params.scrollingElement;
111112
ctx.getHelper = params.helper;
112113
ctx.getDropZones = params.dropzones;
114+
ctx.hasExternalScroll = params.externalScroll;
113115
},
114116
onWillStartDrag: ({ ctx }) => {
115117
ctx.current.container = ctx.getScrollingElement();
116-
ctx.current.helperOffset = { x: 0, y: 0 };
118+
ctx.current.hasExternalScroll = ctx.hasExternalScroll();
119+
ctx.current.helperOffset = {
120+
x: 0,
121+
y: 0,
122+
originalScrollTop: ctx.current.hasExternalScroll
123+
? ctx.getScrollingElement().scrollTop
124+
: 0,
125+
};
117126
},
118127
onDragStart: ({ ctx, addStyle, addCleanup }) => {
119128
// Use the helper as the tracking element to properly update scroll values.
@@ -145,10 +154,12 @@ const dragAndDropHookParams = {
145154
updateElementPosition(ctx.current.helper, ctx.pointer, addStyle, ctx.current.helperOffset);
146155
// Unfortunately, DOMRect is not an Object, so spreading operator from
147156
// `touching` does not work, so convert DOMRect to plain object.
157+
const scrollOffset =
158+
ctx.current.container.scrollTop - ctx.current.helperOffset.originalScrollTop;
148159
let helperRect = ctx.current.helper.getBoundingClientRect();
149160
helperRect = {
150161
x: helperRect.x,
151-
y: helperRect.y,
162+
y: helperRect.y + (ctx.current.hasExternalScroll ? scrollOffset : 0),
152163
width: helperRect.width,
153164
height: helperRect.height,
154165
};

addons/mass_mailing_egg/static/src/iframe/mass_mailing_iframe.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ export class MassMailingIframe extends Component {
294294
// Plugins => provide plugins selection, properly filter excluded Plugins
295295
isMobile: this.state.isMobile,
296296
toggleMobile: () => {
297+
this.iframeRef.el.contentDocument.body.scrollTop = 0;
297298
this.state.isMobile = !this.state.isMobile;
298299
this.throttledResize();
299300
},

0 commit comments

Comments
 (0)