Skip to content

Commit

Permalink
1,495th Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Jun 29, 2024
1 parent 31f4db2 commit 69e615c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions ui/src/composables/scroll-parent/scrollableParent.ts
Original file line number Diff line number Diff line change
@@ -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;
}

Expand Down

0 comments on commit 69e615c

Please sign in to comment.