From 01b595185f034067e21254931b969417f231b59f Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 3 Aug 2021 16:45:09 +0300 Subject: [PATCH] UI: Fixed widget action element click - not correct processing propagation event --- .../components/widget/widget.component.ts | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 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 dee17a000c..8c5a638679 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 @@ -1332,20 +1332,19 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI } private elementClick($event: Event) { - const e = ($event.target || $event.srcElement) as Element; - if (e.id) { - const descriptors = this.getActionDescriptors('elementClick'); - if (descriptors.length) { - descriptors.forEach((descriptor) => { - if (descriptor.name === e.id) { - $event.stopPropagation(); - const entityInfo = this.getActiveEntityInfo(); - const entityId = entityInfo ? entityInfo.entityId : null; - const entityName = entityInfo ? entityInfo.entityName : null; - const entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null; - this.handleWidgetAction($event, descriptor, entityId, entityName, null, entityLabel); - } - }); + const elementClicked = ($event.target || $event.srcElement) as Element; + const descriptors = this.getActionDescriptors('elementClick'); + if (descriptors.length) { + const idsList = descriptors.map(descriptor => `#${descriptor.name}`).join(','); + const targetElement = $(elementClicked).closest(idsList, this.widgetContext.$container[0]); + if (targetElement.length && targetElement[0].id) { + $event.stopPropagation(); + const descriptor = descriptors.find(descriptorInfo => descriptorInfo.name === targetElement[0].id); + const entityInfo = this.getActiveEntityInfo(); + const entityId = entityInfo ? entityInfo.entityId : null; + const entityName = entityInfo ? entityInfo.entityName : null; + const entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null; + this.handleWidgetAction($event, descriptor, entityId, entityName, null, entityLabel); } } }