diff --git a/ui/src/composables/scroll-parent/scrollableParent.ts b/ui/src/composables/scroll-parent/scrollableParent.ts index 0913c76d..2df12144 100644 --- a/ui/src/composables/scroll-parent/scrollableParent.ts +++ b/ui/src/composables/scroll-parent/scrollableParent.ts @@ -1,11 +1,20 @@ -export default (node?: HTMLElement | null): HTMLElement | undefined => { - if (!node) return undefined; +export default (el?: HTMLElement | null): HTMLElement | undefined => { + if (!el) return undefined; - let parent = node.parentElement; + let parent = el.parentElement; while (parent) { const { overflow } = window.getComputedStyle(parent); - if (overflow.split(' ').every((o) => o === 'auto' || o === 'scroll')) return parent; + const hasScrollbarY = parent.scrollHeight > parent.clientHeight; + const hasScrollbarX = parent.scrollWidth > parent.clientWidth; + + if ( + (overflow.includes('auto') || overflow.includes('scroll')) && + (hasScrollbarY || hasScrollbarX) + ) { + return parent; + } + parent = parent.parentElement; }