From c45cadd4783967d270af3a8d8a1def0f6a2a0cc6 Mon Sep 17 00:00:00 2001 From: rusikv Date: Tue, 9 Jul 2024 16:17:36 +0300 Subject: [PATCH] UI: revert checkSize method of widget component, clearing width and height of widget context on destroy --- .../components/widget/widget.component.ts | 19 +++++++++---------- .../home/models/widget-component.models.ts | 2 ++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/widget.component.ts index 533b2fbda2..bae0389e61 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/widget.component.ts @@ -1545,20 +1545,19 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI } private checkSize(): boolean { - const parentWidth = this.widgetContext.$containerParent.width(); - const parentHeight = this.widgetContext.$containerParent.height(); - const width = this.widgetContext.$container?.width(); - const height = this.widgetContext.$container?.height(); + const width = this.widgetContext.$containerParent.width(); + const height = this.widgetContext.$containerParent.height(); let sizeChanged = false; - if (parentWidth > 0 && parentHeight > 0) { - if (!this.widgetContext.width || !this.widgetContext.height || width !== parentWidth || height !== parentHeight) { + if (!this.widgetContext.width || this.widgetContext.width !== width || + !this.widgetContext.height || this.widgetContext.height !== height) { + if (width > 0 && height > 0) { if (this.widgetContext.$container) { - this.widgetContext.$container.css('height', parentHeight + 'px'); - this.widgetContext.$container.css('width', parentWidth + 'px'); + this.widgetContext.$container.css('height', height + 'px'); + this.widgetContext.$container.css('width', width + 'px'); } - this.widgetContext.width = parentWidth; - this.widgetContext.height = parentHeight; + this.widgetContext.width = width; + this.widgetContext.height = height; sizeChanged = true; this.widgetSizeDetected = true; } diff --git a/ui-ngx/src/app/modules/home/models/widget-component.models.ts b/ui-ngx/src/app/modules/home/models/widget-component.models.ts index 581fded240..fbda78a128 100644 --- a/ui-ngx/src/app/modules/home/models/widget-component.models.ts +++ b/ui-ngx/src/app/modules/home/models/widget-component.models.ts @@ -449,6 +449,8 @@ export class WidgetContext { labelPattern.destroy(); } this.labelPatterns.clear(); + this.width = undefined; + this.height = undefined; this.destroyed = true; }