diff --git a/src/utils/dom/style.ts b/src/utils/dom/style.ts index db080c998..8c725a564 100644 --- a/src/utils/dom/style.ts +++ b/src/utils/dom/style.ts @@ -1,5 +1,11 @@ export function isHidden(element: HTMLElement) { - return ( - window.getComputedStyle(element).display === 'none' || element.offsetParent === null - ); + const style = window.getComputedStyle(element); + const isHidden = style.display === 'none'; + + // offsetParent returns null in the following situations: + // 1. The element or its parent element has the display property set to none. + // 2. The element has the position property set to fixed + const isParentHidden = element.offsetParent === null && style.position !== 'fixed'; + + return isHidden || isParentHidden; }