Skip to content

Commit d9b0d64

Browse files
committed
move to connectedCallback
1 parent dd82d27 commit d9b0d64

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
22
import { findAncestorByAttributeValue } from '@umbraco-ui/uui-base/lib/utils';
3-
import { css, html, LitElement, PropertyValues } from 'lit';
3+
import { css, html, LitElement } from 'lit';
44
import { property, state } from 'lit/decorators.js';
55

66
export type PopoverContainerPlacement =
@@ -79,26 +79,24 @@ export class UUIPopoverContainerElement extends LitElement {
7979

8080
super.connectedCallback();
8181
this.addEventListener('beforetoggle', this.#onBeforeToggle);
82-
}
83-
84-
protected override firstUpdated(_changedProperties: PropertyValues): void {
85-
super.firstUpdated(_changedProperties);
8682

87-
this.#sizeObserver = new ResizeObserver(entries => {
88-
const element = entries[0]; // should be only one
89-
const width = element.contentRect.width;
90-
const height = element.contentRect.height;
83+
if (!this.#sizeObserver) {
84+
this.#sizeObserver = new ResizeObserver(entries => {
85+
const element = entries[0]; // should be only one
86+
const width = element.contentRect.width;
87+
const height = element.contentRect.height;
9188

92-
if (width === this.#size.width && height === this.#size.height) {
93-
return; // no change
94-
}
89+
if (width === this.#size.width && height === this.#size.height) {
90+
return; // no change
91+
}
9592

96-
this.#size = { width, height };
97-
this.#initUpdate();
98-
});
93+
this.#size = { width, height };
94+
this.#initUpdate();
95+
});
9996

100-
// start listening for size changes
101-
this.#sizeObserver.observe(this);
97+
// start listening for size changes
98+
this.#sizeObserver.observe(this);
99+
}
102100
}
103101

104102
disconnectedCallback(): void {

0 commit comments

Comments
 (0)