Skip to content
Snippets Groups Projects
Commit b94e6123 authored by Pierre Paridans's avatar Pierre Paridans
Browse files

[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@6e973df114cbc8729c433f14053cdddbdbb0a6c2
X-original-commit: fdd03848e806b42ee0ee778bfd09d2f583b34f16
Related: odoo/enterprise#28215
Signed-off-by: default avatarPierre Paridans (app) <app@odoo.com>
Signed-off-by: default avatarAdrien Dieudonné (adr) <adr@odoo.com>
parent 3ee9041f
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment