diff --git a/src/js/utils/anchor-utils.ts b/src/js/utils/anchor-utils.ts index c99c26cdc..cd674b969 100644 --- a/src/js/utils/anchor-utils.ts +++ b/src/js/utils/anchor-utils.ts @@ -47,7 +47,11 @@ function getRectRelativeToOffsetParent( offsetParent: Element ): Rect { const rect = element.getBoundingClientRect(); - const offsetRect = offsetParent.getBoundingClientRect(); + // offsetParent returns null in the following situations: + // - The element or any ancestor has the display property set to none. + // - The element has the position property set to fixed (Firefox returns ). + // - The element is or . + const offsetRect = offsetParent?.getBoundingClientRect() ?? { x: 0, y: 0 }; return { x: rect.x - offsetRect.x, y: rect.y - offsetRect.y,