From 3a130d4f43d711a8b9f8085eb57b7fa88a4b87eb Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Tue, 7 Feb 2023 13:41:07 +0530 Subject: [PATCH] [ACS-4251] MatMenuItem button container now triggers click on children via querySelector instead of x-y co-ordinates. Removed embedded styles and added classes to the layout for toolbar-menu.component.html --- .../toolbar-menu/toolbar-menu.component.html | 8 +++-- .../toolbar-menu/toolbar-menu.component.ts | 30 +++++++------------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.html b/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.html index bda8b6428..b122df9f0 100644 --- a/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.html +++ b/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.html @@ -12,9 +12,10 @@ - + + - @@ -22,9 +23,10 @@ - + diff --git a/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts b/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts index a105f7f5e..1f0ea4bd1 100644 --- a/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts +++ b/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts @@ -23,17 +23,23 @@ * along with Alfresco. If not, see . */ -import { Component, Input, ViewEncapsulation, HostListener, ViewChild, ViewChildren, QueryList } from '@angular/core'; +import { Component, Input, ViewEncapsulation, HostListener, ViewChild } from '@angular/core'; import { ContentActionRef } from '@alfresco/adf-extensions'; import { MatMenu, MatMenuTrigger } from '@angular/material/menu'; import { ThemePalette } from '@angular/material/core'; -import { ToolbarMenuItemComponent } from '../toolbar-menu-item/toolbar-menu-item.component'; @Component({ selector: 'app-toolbar-menu', templateUrl: './toolbar-menu.component.html', encapsulation: ViewEncapsulation.None, - host: { class: 'app-toolbar-menu' } + host: { class: 'app-toolbar-menu' }, + styles: [ + ` + .aca-mat-menu-item-container { + padding: 0; + } + ` + ] }) export class ToolbarMenuComponent { @Input() @@ -48,9 +54,6 @@ export class ToolbarMenuComponent { @ViewChild(MatMenu) menu: MatMenu; - @ViewChildren(ToolbarMenuItemComponent) - toolbarMenuItems: QueryList; - @HostListener('document:keydown.Escape') handleKeydownEscape() { this.matTrigger.closeMenu(); @@ -61,19 +64,8 @@ export class ToolbarMenuComponent { } onCustomItemContainerClick(event) { - console.log(event); - const el: HTMLElement = event.target; - const x = window.scrollX + el.getBoundingClientRect().left + 5; - const y = window.scrollY + el.getBoundingClientRect().top + 5; - - const opts = { - bubbles: false, - screenX: x, - screenY: y - }; - - const ev = new MouseEvent('click', opts); - document.elementFromPoint(x, y).dispatchEvent(ev); + const ev = new MouseEvent('click'); + event.target.querySelector('.mat-menu-item').dispatchEvent(ev); event.stopPropagation(); } }