From f87a456b485c639a79822e99990ab8e2bfa2ac65 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Wed, 16 Oct 2019 10:10:20 +0900 Subject: [PATCH] refactoring --- .../left-sidenav/group.component.ts | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts index 6939b149..b99e22f2 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts @@ -51,12 +51,7 @@ export class GroupComponent implements OnInit, OnDestroy { @ViewChildren(MatMenuTrigger) menuTriggerList: QueryList; - @ViewChild('profileContextMenu', { static: true }) - profileContextMenu: MatMenu; profileContextMenuPosition = { x: '0px', y: '0px' }; - - @ViewChild('groupContextMenu', { static: true }) - groupContextMenu: MatMenu; groupContextMenuPosition = { x: '0px', y: '0px' }; groupBuddyList$: Observable< @@ -231,13 +226,12 @@ export class GroupComponent implements OnInit, OnDestroy { event.preventDefault(); event.stopPropagation(); - this.profileContextMenu.focusFirstItem('mouse'); - this.profileContextMenuPosition.x = event.clientX + 'px'; this.profileContextMenuPosition.y = event.clientY + 'px'; - const profileContextMenuTrigger = this.menuTriggerList.toArray()[1]; - profileContextMenuTrigger.menuData = { userInfo }; - profileContextMenuTrigger.openMenu(); + const contextMenuTrigger = this.menuTriggerList.toArray()[1]; + contextMenuTrigger.menu.focusFirstItem('mouse'); + contextMenuTrigger.menuData = { userInfo }; + contextMenuTrigger.openMenu(); } onClickGroupContextMenu(menuType: string, group: GroupDetailData) { @@ -254,12 +248,11 @@ export class GroupComponent implements OnInit, OnDestroy { params.event.preventDefault(); params.event.stopPropagation(); - this.groupContextMenu.focusFirstItem('mouse'); - this.groupContextMenuPosition.x = params.event.clientX + 'px'; this.groupContextMenuPosition.y = params.event.clientY + 'px'; - const groupContextMenuTrigger = this.menuTriggerList.toArray()[2]; - groupContextMenuTrigger.menuData = { group: params.group }; - groupContextMenuTrigger.openMenu(); + const contextMenuTrigger = this.menuTriggerList.toArray()[2]; + contextMenuTrigger.menu.focusFirstItem('mouse'); + contextMenuTrigger.menuData = { group: params.group }; + contextMenuTrigger.openMenu(); } }