[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
This commit is contained in:
Benjamin Vray
2021-12-09 18:40:45 +00:00
parent 18b0477006
commit ea650d80b8
+4 -1
View File
@@ -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');
}
},