Account for scroll offset when using non-mouse positioning

offsetTop includes the scroll offset, so when using it to
calculate clientTop (position relative to the viewport),
we need to substract that offset.

clientY comes from mouse events and is already relative
to the viewport so needs no adjustment.

Bug: T270215
Change-Id: I545b14059f416678fc0d35413a76334e57bfc495
This commit is contained in:
Ed Sanders 2024-03-21 12:13:12 +00:00
parent b46fc85941
commit d4b0d10b13
3 changed files with 1 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View file

@ -381,7 +381,7 @@ export function createLayout(
// Position according to link position or size // Position according to link position or size
measures.offset.top + measures.height + pointerSize, measures.offset.top + measures.height + pointerSize,
offsetLeft; offsetLeft;
const clientTop = measures.clientY ? measures.clientY : offsetTop; const clientTop = measures.clientY ? measures.clientY : offsetTop - measures.scrollTop;
if ( measures.pageX ) { if ( measures.pageX ) {
if ( measures.width > maxLinkWidthForCenteredPointer ) { if ( measures.width > maxLinkWidthForCenteredPointer ) {