Skip to content

Commit fe2ea09

Browse files
committed
traverse shadowDOMs for scroll containers
1 parent 80850b6 commit fe2ea09

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/uui-popover-container/lib/uui-popover-container.element.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ export class UUIPopoverContainerElement extends LitElement {
332332
? /(auto|scroll|hidden)/
333333
: /(auto|scroll)/;
334334

335-
let el = this.#targetElement;
336-
while ((el = el.parentElement as HTMLElement)) {
335+
let el: HTMLElement | undefined | null = this.#targetElement;
336+
while (el) {
337337
style = getComputedStyle(el);
338338

339339
if (excludeStaticParent && style.position === 'static') {
@@ -347,6 +347,13 @@ export class UUIPopoverContainerElement extends LitElement {
347347
if (style.position === 'fixed') {
348348
return;
349349
}
350+
351+
if (el.parentElement) {
352+
el = el.parentElement;
353+
} else {
354+
// If we had no parentElement, then check for shadow roots:
355+
el = (el.getRootNode() as any)?.host;
356+
}
350357
}
351358
this.#scrollParents.push(document.body);
352359
}

0 commit comments

Comments
 (0)