diff --git a/packages/lexical-react/src/shared/LexicalMenu.ts b/packages/lexical-react/src/shared/LexicalMenu.ts index 62b0dc8e3a0..590e5cfdc57 100644 --- a/packages/lexical-react/src/shared/LexicalMenu.ts +++ b/packages/lexical-react/src/shared/LexicalMenu.ts @@ -494,7 +494,9 @@ export function useMenuAnchorRef( if (rootElement !== null && resolution !== null) { const {left, top, width, height} = resolution.getRect(); const anchorHeight = anchorElementRef.current.offsetHeight; // use to position under anchor - containerDiv.style.top = `${top + anchorHeight + 3}px`; + containerDiv.style.top = `${ + top + window.pageYOffset + anchorHeight + 3 + }px`; containerDiv.style.left = `${left + window.pageXOffset}px`; containerDiv.style.height = `${height}px`; containerDiv.style.width = `${width}px`; @@ -516,7 +518,9 @@ export function useMenuAnchorRef( top + menuHeight > rootElementRect.bottom) && top - rootElementRect.top > menuHeight + height ) { - containerDiv.style.top = `${top - menuHeight - height}px`; + containerDiv.style.top = `${ + top - menuHeight + window.pageYOffset - height + }px`; } }