Skip to content

Commit 4d46b8d

Browse files
committed
fix: only exclude static parents if the previous element was no static (recalculate every time)
1 parent a20d69b commit 4d46b8d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export class UUIPopoverContainerElement extends LitElement {
356356
}
357357

358358
const includeHidden = false;
359-
const excludeStaticParent = style.position === 'absolute';
359+
let excludeStaticParent = style.position === 'absolute';
360360
const overflowRegex = includeHidden
361361
? /(auto|scroll|hidden)/
362362
: /(auto|scroll)/;
@@ -369,6 +369,11 @@ export class UUIPopoverContainerElement extends LitElement {
369369
el = this.#getAncestorElement(el);
370370
continue;
371371
}
372+
373+
if (style.position !== 'static') {
374+
excludeStaticParent = style.position === 'absolute';
375+
}
376+
372377
if (
373378
overflowRegex.test(style.overflow + style.overflowY + style.overflowX)
374379
) {
@@ -386,10 +391,10 @@ export class UUIPopoverContainerElement extends LitElement {
386391
#getAncestorElement(el: HTMLElement | null): HTMLElement | null {
387392
if (el?.parentElement) {
388393
return el.parentElement;
389-
} else {
390-
// If we had no parentElement, then check for shadow roots:
391-
return (el?.getRootNode() as any)?.host;
392394
}
395+
396+
// If we had no parentElement, then check for shadow roots:
397+
return (el?.getRootNode() as any)?.host;
393398
}
394399

395400
render() {

0 commit comments

Comments
 (0)