From 07a95abd2f2ec2a5ebafce6633f92932087c1bd0 Mon Sep 17 00:00:00 2001
From: Jenny Yu <jennyyu212@outlook.com>
Date: Wed, 15 Jun 2022 17:48:54 -0700
Subject: not triggering context menu event

---
 src/client/views/DashboardView.tsx | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

(limited to 'src/client/views/DashboardView.tsx')

diff --git a/src/client/views/DashboardView.tsx b/src/client/views/DashboardView.tsx
index 027cfd376..f754c1ff5 100644
--- a/src/client/views/DashboardView.tsx
+++ b/src/client/views/DashboardView.tsx
@@ -12,6 +12,8 @@ import { MainViewModal } from "./MainViewModal";
 import { ContextMenu } from "./ContextMenu";
 import { DocumentManager } from "../util/DocumentManager";
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { ContextMenuProps } from "./ContextMenuItem";
+import { simulateMouseClick } from "../../Utils";
 
 enum DashboardGroup {
       MyDashboards, SharedDashboards
@@ -58,6 +60,25 @@ export class DashboardView extends React.Component {
             this.abortCreateNewDashboard();
       }
 
+      onContextMenu = (e: React.MouseEvent): void => {
+            ContextMenu.Instance.addItem({
+                  description: "Share Dashboard", event: async () => {
+                     // ...
+                  }, icon: "edit"
+            });
+            ContextMenu.Instance.addItem({
+                  description: "Delete Dashboard", event: async () => {
+                     // ...
+                  }, icon: "trash"
+            });
+        }
+
+        showContextMenu = (e: React.MouseEvent) => {
+            // DocumentViewInternal.SelectAfterContextMenu = false;
+            // simulateMouseClick(this._docRef?.ContentDiv, e.clientX, e.clientY + 30, e.screenX, e.screenY + 30);
+            // DocumentViewInternal.SelectAfterContextMenu = true;
+        }
+
       @computed
       get namingInterface() {
             return <div>
@@ -82,21 +103,7 @@ export class DashboardView extends React.Component {
                                           <img src={href ?? "https://media.istockphoto.com/photos/hot-air-balloons-flying-over-the-botan-canyon-in-turkey-picture-id1297349747?b=1&k=20&m=1297349747&s=170667a&w=0&h=oH31fJty_4xWl_JQ4OIQWZKP8C6ji9Mz7L4XmEnbqRU="}></img>
                                           <div className="info">
                                                 <div className="title"> {StrCast(dashboard.title)} </div>
-                                                <div className="more" onClick={e => {
-                                                      const dashView = DocumentManager.Instance.getDocumentView(dashboard);
-                                                      console.log(dashView)
-                                                      ContextMenu.Instance.addItem({
-                                                            description: "Share Dashboard", event: async () => {
-                                                               // ...
-                                                            }, icon: "edit"
-                                                      });
-                                                      ContextMenu.Instance.addItem({
-                                                            description: "Delete Dashboard", event: async () => {
-                                                               // ...
-                                                            }, icon: "trash"
-                                                      });
-                                                      dashView?.showContextMenu(e.clientX + 20, e.clientY + 30);
-                                                }}>
+                                                <div className="more" onClick={this.showContextMenu} onContextMenu={this.onContextMenu}>
                                                       <FontAwesomeIcon color="black" size="lg" icon="bars" />
                                                 </div>
                                           </div>
-- 
cgit v1.2.3-70-g09d2

