Skip to content

Commit 33fae61

Browse files
committed
Fix stuck while loop where the checked element never got updated
1 parent a2e6078 commit 33fae61

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ export class UUIPopoverContainerElement extends LitElement {
359359
style = getComputedStyle(el);
360360

361361
if (excludeStaticParent && style.position === 'static') {
362+
el = this.#getAncestorElement(el);
362363
continue;
363364
}
364365
if (
@@ -370,16 +371,20 @@ export class UUIPopoverContainerElement extends LitElement {
370371
return;
371372
}
372373

373-
if (el.parentElement) {
374-
el = el.parentElement;
375-
} else {
376-
// If we had no parentElement, then check for shadow roots:
377-
el = (el.getRootNode() as any)?.host;
378-
}
374+
el = this.#getAncestorElement(el);
379375
}
380376
this.#scrollParents.push(document.body);
381377
}
382378

379+
#getAncestorElement(el: HTMLElement | null): HTMLElement | null {
380+
if (el?.parentElement) {
381+
return el.parentElement;
382+
} else {
383+
// If we had no parentElement, then check for shadow roots:
384+
return (el?.getRootNode() as any)?.host;
385+
}
386+
}
387+
383388
render() {
384389
return html`<slot></slot>`;
385390
}

0 commit comments

Comments
 (0)