Skip to content

Commit 7fa3ede

Browse files
committed
fix(popover): disconnect ResizeObserver in disconnectedCallback
1 parent de3ab99 commit 7fa3ede

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

core/src/components/popover/popover.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class Popover implements ComponentInterface, PopoverInterface {
6464
private destroyTriggerInteraction?: () => void;
6565
private destroyKeyboardInteraction?: () => void;
6666
private destroyDismissInteraction?: () => void;
67+
private headerResizeObserver?: ResizeObserver;
6768

6869
private inline = false;
6970
private workingDelegate?: FrameworkDelegate;
@@ -361,6 +362,11 @@ export class Popover implements ComponentInterface, PopoverInterface {
361362
if (destroyTriggerInteraction) {
362363
destroyTriggerInteraction();
363364
}
365+
366+
if (this.headerResizeObserver) {
367+
this.headerResizeObserver.disconnect();
368+
this.headerResizeObserver = undefined;
369+
}
364370
}
365371

366372
componentWillLoad() {
@@ -562,16 +568,17 @@ export class Popover implements ComponentInterface, PopoverInterface {
562568
return;
563569
}
564570

565-
const ro = new ResizeObserver(async () => {
571+
this.headerResizeObserver = new ResizeObserver(async () => {
566572
if (header.offsetHeight > 0) {
567-
ro.disconnect();
573+
this.headerResizeObserver?.disconnect();
574+
this.headerResizeObserver = undefined;
568575
for (const contentEl of contentElements) {
569576
await contentEl.recalculateDimensions();
570577
}
571578
}
572579
});
573580

574-
ro.observe(header);
581+
this.headerResizeObserver.observe(header);
575582
}
576583

577584
/**

0 commit comments

Comments
 (0)