diff --git a/packages/stage/src/util.ts b/packages/stage/src/util.ts index 4ab4c3f2..9a5ceeaa 100644 --- a/packages/stage/src/util.ts +++ b/packages/stage/src/util.ts @@ -118,15 +118,17 @@ export const getMode = (el: HTMLElement): Mode => { export const getScrollParent = (element: HTMLElement, includeHidden = false): HTMLElement | null => { let style = getComputedStyle(element); + const excludeStaticParent = style.position === 'absolute'; const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/; - if (isFixed(element)) return null; + if (style.position === 'fixed') return null; + for (let parent = element; parent.parentElement; ) { parent = parent.parentElement; style = getComputedStyle(parent); - if (isAbsolute(element) && isStatic(element)) { - continue; - } + + if (excludeStaticParent && style.position === 'static') continue; + if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent; }