Commit 3b5f0642 authored by Stephane Zermatten's avatar Stephane Zermatten Committed by Commit Bot

[Autofill Assistant] Fix race condition while scrolling in Focus action.

Before this change, the Focus action usually scrolled smoothly elements
into view at 1/4 of the screen size. This sometimes failed, as right
after smooth scrolling started, scrollIntoViewIfNeeded is called which,
if it scrolls something, interrupts the smooth scrolling. The result is
that the element is sometimes left too low on the screen - though always
visible.

This change disables smooth scrolling, which avoids the race condition.
The cost of that is that we lose the nice scrolling animation.

Bug: b/132137331
Change-Id: I9f43e8a26cea6d6202262dd8b84a60efd45f9e8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599451Reviewed-by: default avatarMathias Carlen <mcarlen@chromium.org>
Commit-Queue: Stephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658538}
parent 1318c3b1
...@@ -61,10 +61,9 @@ const char* const kScrollIntoViewScript = ...@@ -61,10 +61,9 @@ const char* const kScrollIntoViewScript =
R"(function(node) { R"(function(node) {
const rect = node.getBoundingClientRect(); const rect = node.getBoundingClientRect();
if (rect.height < window.innerHeight) { if (rect.height < window.innerHeight) {
window.scrollBy({top: rect.top - window.innerHeight * 0.25, window.scrollBy({top: rect.top - window.innerHeight * 0.25});
behavior: 'smooth'});
} else { } else {
window.scrollBy({top: rect.top, behavior: 'smooth'}); window.scrollBy({top: rect.top});
} }
node.scrollIntoViewIfNeeded(); node.scrollIntoViewIfNeeded();
})"; })";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment