From ea650d80b8ff6cdc65156185487b1cfd302f0265 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Thu, 9 Dec 2021 09:00:53 +0000 Subject: [PATCH] [FIX] web: fix scrollbar width compensation when a modal is open Before this commit, when we calculated the width of the scrollbar to compensate when a modal is open. We did not take into account the wrapwrap borders applied with some headers. (e.g. the sidebar header) task-2677132 X-original-commit: 990d0f6a53047db4238c7d6a15be12e58ed1fe86 Part-of: odoo/odoo#81151 --- addons/web/static/src/legacy/js/libs/jquery.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/js/libs/jquery.js b/addons/web/static/src/legacy/js/libs/jquery.js index 7fc19bf1d94..38944b4bf2e 100644 --- a/addons/web/static/src/legacy/js/libs/jquery.js +++ b/addons/web/static/src/legacy/js/libs/jquery.js @@ -157,7 +157,10 @@ $.fn.extend({ } const scrollableEl = isScrollElement ? el : $(el).parent().closestScrollable()[0]; const style = window.getComputedStyle(el); - const newValue = parseInt(style[cssProperty]) + scrollableEl.offsetWidth - scrollableEl.clientWidth; + const borderLeftWidth = parseInt(style.borderLeftWidth.replace('px', '')); + const borderRightWidth = parseInt(style.borderRightWidth.replace('px', '')); + const bordersWidth = borderLeftWidth + borderRightWidth; + const newValue = parseInt(style[cssProperty]) + scrollableEl.offsetWidth - scrollableEl.clientWidth - bordersWidth; el.style.setProperty(cssProperty, `${newValue}px`, 'important'); } },