summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/web/static/src/js/core/dom.js8
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.editor.js5
2 files changed, 8 insertions, 5 deletions
diff --git a/addons/web/static/src/js/core/dom.js b/addons/web/static/src/js/core/dom.js
index e0b0f67ef6d..4af811d41bc 100644
--- a/addons/web/static/src/js/core/dom.js
+++ b/addons/web/static/src/js/core/dom.js
@@ -518,7 +518,13 @@ var dom = {
const isTopScroll = $scrollable.is($topLevelScrollable);
function _computeScrollTop() {
- const elPosition = $scrollable[0].scrollTop + ($el.offset().top - $scrollable.offset().top);
+ let offsetTop = $el.offset().top;
+ if (el.classList.contains('d-none')) {
+ el.classList.remove('d-none');
+ offsetTop = $el.offset().top;
+ el.classList.add('d-none');
+ }
+ const elPosition = $scrollable[0].scrollTop + (offsetTop - $scrollable.offset().top);
let offset = options.forcedOffset;
if (offset === undefined) {
offset = (isTopScroll ? dom.scrollFixedOffset() : 0) + (options.extraOffset || 0);
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 dff27ed70e0..b4a5dca1d4b 100644
--- a/addons/web_editor/static/src/js/editor/snippets.editor.js
+++ b/addons/web_editor/static/src/js/editor/snippets.editor.js
@@ -1825,7 +1825,6 @@ var SnippetsMenu = Widget.extend({
_makeSnippetDraggable: function ($snippets) {
var self = this;
var $toInsert, dropped, $snippet;
- let scrollValue;
let dragAndDropResolve;
@@ -1880,7 +1879,6 @@ var SnippetsMenu = Widget.extend({
over: function () {
if (!dropped) {
dropped = true;
- scrollValue = $(this).first().offset().top;
$(this).first().after($toInsert).addClass('d-none');
$toInsert.removeClass('oe_snippet_body');
}
@@ -1905,7 +1903,6 @@ var SnippetsMenu = Widget.extend({
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();
if ($el.length) {
- scrollValue = $el.offset().top;
$el.after($toInsert);
dropped = true;
}
@@ -1933,7 +1930,7 @@ var SnippetsMenu = Widget.extend({
}
var $target = $toInsert;
- await self._scrollToSnippet($target, scrollValue);
+ await self._scrollToSnippet($target);
_.defer(async function () {
self.trigger_up('snippet_dropped', {$target: $target});