diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts b/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts index 698b78eaa7..b45b3432c4 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/widget-container.component.ts @@ -148,7 +148,10 @@ export class WidgetContainerComponent extends PageComponent implements OnInit, O $(this.gridsterItem.el).on('mousedown', (e) => this.onMouseDown(e.originalEvent)); $(this.gridsterItem.el).on('click', (e) => this.onClicked(e.originalEvent)); $(this.gridsterItem.el).on('contextmenu', (e) => this.onContextMenu(e.originalEvent)); - this.initEditWidgetActionTooltip(); + const dashboardElement = this.widget.widgetContext.dashboardPageElement; + if (dashboardElement) { + this.initEditWidgetActionTooltip(dashboardElement); + } } ngAfterViewInit(): void { @@ -251,11 +254,10 @@ export class WidgetContainerComponent extends PageComponent implements OnInit, O } } - private initEditWidgetActionTooltip() { + private initEditWidgetActionTooltip(parent: HTMLElement) { from(import('tooltipster')).subscribe(() => { - const dashboardElement = this.widget.widgetContext.dashboard.stateController.dashboardCtrl.elRef.nativeElement; $(this.gridsterItem.el).tooltipster({ - parent: $(dashboardElement), + parent: $(parent), delay: this.widget.selected ? [0, 10000000] : [0, 100], distance: 2, zIndex: 151, @@ -275,7 +277,7 @@ export class WidgetContainerComponent extends PageComponent implements OnInit, O content: '', functionPosition: (instance, helper, position) => { const clientRect = helper.origin.getBoundingClientRect(); - const container = dashboardElement.getBoundingClientRect(); + const container = parent.getBoundingClientRect(); position.coord.left = clientRect.right - position.size.width - container.left; position.coord.top = position.coord.top - container.top; position.target = clientRect.right; 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 1441bd4e92..bad8615363 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 @@ -180,6 +180,10 @@ export class WidgetContext { } } + get dashboardPageElement(): HTMLElement { + return this.dashboard?.stateController?.dashboardCtrl?.elRef?.nativeElement; + } + authService: AuthService; deviceService: DeviceService; assetService: AssetService;