summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2020-07-13 14:29:36 +0000
committerqsm-odoo <qsm@odoo.com>2020-07-13 15:24:07 +0000
commitb9ad60d5ebe73ee47eba64145ebe27d483a7f33a (patch)
treed60d3664af64b397e28e6b3704c08c750343da4c /addons/web/static/src/js/core
parentb558cb7996b1de385f6bf7cb3918f0e37cee69fe (diff)
[FIX] web_editor, web: fix traceback with drag & drop when no header
Commit [1] introduced the bug by relying on the fact an element with id=top is in the edited DOM. As the website header can be disabled, this induced a crash as soon as the header was indeed disabled. Also, the editor is not meant to edit the website only so we cannot rely at all on the presence of a #top element. [1]: https://github.com/odoo/odoo/commit/6df67a28c2f113572acd4a3db19ab6b1bd37e7da closes odoo/odoo#54409 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/core')
-rw-r--r--addons/web/static/src/js/core/smooth_scroll_on_drag.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/web/static/src/js/core/smooth_scroll_on_drag.js b/addons/web/static/src/js/core/smooth_scroll_on_drag.js
index 71ea347ed9d..a53323174cf 100644
--- a/addons/web/static/src/js/core/smooth_scroll_on_drag.js
+++ b/addons/web/static/src/js/core/smooth_scroll_on_drag.js
@@ -21,25 +21,25 @@ const OffsetElementsHelper = Class.extend({
this.offsetElements = offsetElements;
},
top: function () {
- if (!this.offsetElements.$top) {
+ if (!this.offsetElements.$top || !this.offsetElements.$top.length) {
return 0;
}
return this.offsetElements.$top.get(0).getBoundingClientRect().bottom;
},
right: function () {
- if (!this.offsetElements.$right) {
+ if (!this.offsetElements.$right || !this.offsetElements.$right.length) {
return 0;
}
return this.offsetElements.$right.get(0).getBoundingClientRect().left;
},
bottom: function () {
- if (!this.offsetElements.$bottom) {
+ if (!this.offsetElements.$bottom || !this.offsetElements.$bottom.length) {
return 0;
}
return this.offsetElements.$bottom.get(0).getBoundingClientRect().top;
},
left: function () {
- if (!this.offsetElements.$left) {
+ if (!this.offsetElements.$left || !this.offsetElements.$left.length) {
return 0;
}
return this.offsetElements.$left.get(0).getBoundingClientRect().right;