[FIX] web: scrolling element to bottom border test breaks in Chrome 94+

Since Chrome 94, some element's sizing computation returns a slightly
different value (in the order of a fraction of a pixel). Sadly, due to
rounding, this difference has an impact on exact sizing assertion.

In this case, assertion regarding the scrolling of an element inside its
scrollable container when it should be aligned to the bottom of the
container while being fully visible breaks due to those rounding change
(cf. the element is +/- 1px too low).

This commit fixes it by adjusting the `scrollTo()` implementation to
round the height of the element that should be visible in its scrollable
element to the upper pixel. This allows the element to remain fully
visible, with eventually a 1px margin in some cases (taken as an
reasonnable margin of error).

closes odoo/odoo#93235

Note: similar issue was also addressed in commit odoo/enterprise@6e973df114
X-original-commit: fdd03848e806b42ee0ee778bfd09d2f583b34f16
Related: odoo/enterprise#28215
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
This commit is contained in:
Pierre Paridans
2022-06-09 18:57:46 +02:00
parent 3ee9041f62
commit b94e612378
@@ -32,7 +32,7 @@ export function scrollTo(element, options = { scrollable: null, isAnchor: false
if (elementBottom > scrollBottom && !options.isAnchor) {
// The scroll place the element at the bottom border of the scrollable
scrollable.scrollTop +=
elementTop - scrollBottom + element.getBoundingClientRect().height;
elementTop - scrollBottom + Math.ceil(element.getBoundingClientRect().height);
} else if (elementTop < scrollTop || options.isAnchor) {
// The scroll place the element at the top of the scrollable
scrollable.scrollTop -= scrollTop - elementTop;