100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Changed MutationObserver to ResizeObserver when setting select menu width for better dialog support. Also fixed individual case described in #896 (#907)
Martin Peeters1fb7a11f8065
diff --git a/ui/component/or-mwc-components/src/or-mwc-input.ts b/ui/component/or-mwc-components/src/or-mwc-input.tsindex 7c8be52d3..6b0e96521 100644--- a/ui/component/or-mwc-components/src/or-mwc-input.ts+++ b/ui/component/or-mwc-components/src/or-mwc-input.ts@@ -1507,8 +1507,10 @@ export class OrMwcInput extends LitElement {// Set width of fixed select menu to match the component width// Using an observer to prevent forced reflow / DOM measurements; prevents blocking the thread- const observer = new IntersectionObserver((entries, observer) => {- (entries[0].target as HTMLElement).style.width = entries[0].boundingClientRect.width + "px";+ // ResizeObserver is required instead of MutationObserver to allow rendering without painting it.+ // (such as a dialog where it's initial width is 0px, but when opened it changes)+ const observer = new ResizeObserver((entries, observer) => {+ (entries[0].target as HTMLElement).style.width = entries[0].contentRect.width + "px";observer.unobserve(entries[0].target);})observer.observe(this.shadowRoot!.getElementById("component")!);diff --git a/ui/component/or-rules/src/or-rule-validity.ts b/ui/component/or-rules/src/or-rule-validity.tsindex e6e48663d..6618b9a44 100644--- a/ui/component/or-rules/src/or-rule-validity.ts+++ b/ui/component/or-rules/src/or-rule-validity.ts@@ -306,7 +306,7 @@ export class OrRuleValidity extends translate(i18next)(LitElement) {return html`<div style="min-width: 635px; display:grid; flex-direction: row;"><div class="layout horizontal">- <or-mwc-input .value="${validityType}" .type="${InputType.SELECT}" .options="${validityTypes}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.setValidityType(e.detail.value)}" ></or-mwc-input>+ <or-mwc-input style="min-width: 280px;" .value="${validityType}" .type="${InputType.SELECT}" .options="${validityTypes}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.setValidityType(e.detail.value)}" ></or-mwc-input></div>${validity && (validityType === "validityPeriod" || validityType === "validityRecurrence") ? html`