|
1 | 1 | import { defineElement } from '@umbraco-ui/uui-base/lib/registration'; |
2 | 2 | import { findAncestorByAttributeValue } from '@umbraco-ui/uui-base/lib/utils'; |
3 | | -import { css, html, LitElement, PropertyValues } from 'lit'; |
| 3 | +import { css, html, LitElement } from 'lit'; |
4 | 4 | import { property, state } from 'lit/decorators.js'; |
5 | 5 |
|
6 | 6 | export type PopoverContainerPlacement = |
@@ -79,26 +79,24 @@ export class UUIPopoverContainerElement extends LitElement { |
79 | 79 |
|
80 | 80 | super.connectedCallback(); |
81 | 81 | this.addEventListener('beforetoggle', this.#onBeforeToggle); |
82 | | - } |
83 | | - |
84 | | - protected override firstUpdated(_changedProperties: PropertyValues): void { |
85 | | - super.firstUpdated(_changedProperties); |
86 | 82 |
|
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; |
91 | 88 |
|
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 | + } |
95 | 92 |
|
96 | | - this.#size = { width, height }; |
97 | | - this.#initUpdate(); |
98 | | - }); |
| 93 | + this.#size = { width, height }; |
| 94 | + this.#initUpdate(); |
| 95 | + }); |
99 | 96 |
|
100 | | - // start listening for size changes |
101 | | - this.#sizeObserver.observe(this); |
| 97 | + // start listening for size changes |
| 98 | + this.#sizeObserver.observe(this); |
| 99 | + } |
102 | 100 | } |
103 | 101 |
|
104 | 102 | disconnectedCallback(): void { |
|
0 commit comments