diff options
| author | qsm-odoo <qsm@odoo.com> | 2020-09-24 11:33:35 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2020-09-24 11:33:35 +0000 |
| commit | ebd0c90a146145079061e79c2d4c37fa182a2975 (patch) | |
| tree | 5ae193c2029790f43e7c54a0771647f4f6bb34d3 /addons/web/static/src/js/libs/jquery.js | |
| parent | b94f54b5cdcbb58300a643a9c39f8c9d4842e41b (diff) | |
[FIX] website, *: review modal behaviors with right-panelization
*: web, web_editor
Since the right-panelization made with [1], the modals were not
compensating the body scrollbar when opened anymore and the backdrop
was misplaced. This commit fixes the problems generically, to support
modals with non-body scrolling.
[1]: https://github.com/odoo/odoo/pull/57975
closes odoo/odoo#58414
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/libs/jquery.js')
| -rw-r--r-- | addons/web/static/src/js/libs/jquery.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/web/static/src/js/libs/jquery.js b/addons/web/static/src/js/libs/jquery.js index 6921b004019..7c3273abc91 100644 --- a/addons/web/static/src/js/libs/jquery.js +++ b/addons/web/static/src/js/libs/jquery.js @@ -136,6 +136,28 @@ $.fn.extend({ return $el; }, /** + * Adapt the given css property by adding the size of a scrollbar if any. + * Limitation: only works if the given css property is not already used as + * inline style for another reason. + * + * @param {boolean} [add=true] + * @param {boolean} [isScrollElement=true] + * @param {string} [cssProperty='padding-right'] + */ + compensateScrollbar(add = true, isScrollElement = true, cssProperty = 'padding-right') { + for (const el of this) { + // Compensate scrollbar + el.style.removeProperty(cssProperty); + if (!add) { + return; + } + const scrollableEl = isScrollElement ? el : $(el).parent().closestScrollable()[0]; + const style = window.getComputedStyle(el); + const newValue = parseInt(style[cssProperty]) + scrollableEl.offsetWidth - scrollableEl.clientWidth; + el.style.setProperty(cssProperty, `${newValue}px`, 'important'); + } + }, + /** * @returns {jQuery} */ getScrollingElement() { |
