Commit 8174568dfae375247efe0805216de6d3dcfceeb4

Authored by Igor Kulikov
Committed by GitHub
2 parents 831ff5c7 01b59518

Merge pull request #5024 from vvlladd28/bug/action/element-click/propagation

[3.3.0] UI: Fixed widget action element click - not correct processing propagation event
... ... @@ -1326,20 +1326,19 @@ export class WidgetComponent extends PageComponent implements OnInit, AfterViewI
1326 1326 }
1327 1327
1328 1328 private elementClick($event: Event) {
1329   - const e = ($event.target || $event.srcElement) as Element;
1330   - if (e.id) {
1331   - const descriptors = this.getActionDescriptors('elementClick');
1332   - if (descriptors.length) {
1333   - descriptors.forEach((descriptor) => {
1334   - if (descriptor.name === e.id) {
1335   - $event.stopPropagation();
1336   - const entityInfo = this.getActiveEntityInfo();
1337   - const entityId = entityInfo ? entityInfo.entityId : null;
1338   - const entityName = entityInfo ? entityInfo.entityName : null;
1339   - const entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null;
1340   - this.handleWidgetAction($event, descriptor, entityId, entityName, null, entityLabel);
1341   - }
1342   - });
  1329 + const elementClicked = ($event.target || $event.srcElement) as Element;
  1330 + const descriptors = this.getActionDescriptors('elementClick');
  1331 + if (descriptors.length) {
  1332 + const idsList = descriptors.map(descriptor => `#${descriptor.name}`).join(',');
  1333 + const targetElement = $(elementClicked).closest(idsList, this.widgetContext.$container[0]);
  1334 + if (targetElement.length && targetElement[0].id) {
  1335 + $event.stopPropagation();
  1336 + const descriptor = descriptors.find(descriptorInfo => descriptorInfo.name === targetElement[0].id);
  1337 + const entityInfo = this.getActiveEntityInfo();
  1338 + const entityId = entityInfo ? entityInfo.entityId : null;
  1339 + const entityName = entityInfo ? entityInfo.entityName : null;
  1340 + const entityLabel = entityInfo && entityInfo.entityLabel ? entityInfo.entityLabel : null;
  1341 + this.handleWidgetAction($event, descriptor, entityId, entityName, null, entityLabel);
1343 1342 }
1344 1343 }
1345 1344 }
... ...