Skip to content

Fix stuck while loop where the checked element never gets updated #1140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ export class UUIPopoverContainerShadowDomTesterElement extends LitElement {
return html`<div
style="height: 500px; overflow: auto; outline: 1px solid black">
<div
style="width: 300px; height: 300px; outline: 1px solid black; overflow: auto;">
style="position:relative; width: 300px; height: 300px; outline: 1px solid black; overflow: auto;">
<div style="height: 150px"></div>
<uui-button
id="popover-button"
style="position: absolute; top: 50px; left: 50px;"
popovertarget="popover-container"
look="primary"
label="Open popover">
Expand All @@ -28,7 +29,8 @@ export class UUIPopoverContainerShadowDomTesterElement extends LitElement {
<div
style="width: 100%; background-color: var(--uui-color-surface); max-width: 200px; box-shadow: var(--uui-shadow-depth-4); padding: var(--uui-size-space-4); border-radius: var(--uui-border-radius); font-size: 0.9rem;">
<h3>Scroll!</h3>
Scrolling in any of the 2 boxes should trigger an update
Scrolling in any of the 2 boxes that are in a shadow-dom inside 2
boxes should trigger an update
</div>
</uui-popover-container>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ export class UUIPopoverContainerElement extends LitElement {
style = getComputedStyle(el);

if (excludeStaticParent && style.position === 'static') {
el = this.#getAncestorElement(el);
continue;
}
if (
Expand All @@ -370,16 +371,20 @@ export class UUIPopoverContainerElement extends LitElement {
return;
}

if (el.parentElement) {
el = el.parentElement;
} else {
// If we had no parentElement, then check for shadow roots:
el = (el.getRootNode() as any)?.host;
}
el = this.#getAncestorElement(el);
}
this.#scrollParents.push(document.body);
}

#getAncestorElement(el: HTMLElement | null): HTMLElement | null {
if (el?.parentElement) {
return el.parentElement;
} else {
// If we had no parentElement, then check for shadow roots:
return (el?.getRootNode() as any)?.host;
}
}

render() {
return html`<slot></slot>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const InsideShadowDOMScrollContainer: Story = {
render: () => html`
<div style="height: 500px; overflow: auto; outline: 1px solid black">
<div
style="width: 300px; height: 300px; outline: 1px solid black; overflow: auto;">
style="position:static; width: 300px; height: 300px; outline: 1px solid black; overflow: auto;">
<div style="height: 150px"></div>
<uui-popover-container-shadowdomtester></uui-popover-container-shadowdomtester>
<div style="height: 150px"></div>
Expand Down
Loading