Skip to content

Commit

Permalink
fix(scrollableParent): check hasScrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Jun 28, 2024
1 parent 31f4db2 commit cff18a9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/src/composables/scroll-parent/scrollableParent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ export default (node?: HTMLElement | null): HTMLElement | undefined => {

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.split(' ').every((o) => o === 'auto' || o === 'scroll') &&
(hasScrollbarY || hasScrollbarX)
) {
return parent;
}

parent = parent.parentElement;
}

Expand Down

0 comments on commit cff18a9

Please sign in to comment.