Scroll to diff row when it is near the top
The scroll checking code is not aware of the sticky header UI that
covers the top of the diff and will not try to scroll rows out from
underneath the header.
To fix this we can consider elements close to the top (100px) to be
offscreen and then run our normal code to bring them 1/3rd down the
screen as we do with when scrolling to other offscreen rows.
also, pageYOffset is marked deprecated and is an alias for scrollY,
so they are converted to scrollY. We already use scrollY elsewhere.
Google-Bug-Id: b/317815912
Release-Notes: Fix scrolling to diff rows covered by the header UI
Change-Id: I20eeef32a483bc29c33333ad8206bd503205bfe7
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
index 828672b..35567be 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
@@ -391,10 +391,12 @@
}
_targetIsVisible(top: number) {
+ // Targets near the top are often covered by sticky header UI, so we
+ // consider it not-visible if it is within 100px of the top.
return (
this.scrollMode === ScrollMode.KEEP_VISIBLE &&
- top > window.pageYOffset &&
- top < window.pageYOffset + window.innerHeight
+ top > window.scrollY + 100 &&
+ top < window.scrollY + window.innerHeight
);
}