From 46de24b2e5c2cbaf12d0f8e6d0974979c3cfbcd7 Mon Sep 17 00:00:00 2001
From: laurawilsonri <laura_wilson@brown.edu>
Date: Mon, 11 Mar 2019 19:49:27 -0400
Subject: changed context menu so that it doesn't zoom in too much when screen
 width is large and bounded it to screen

---
 src/client/views/ContextMenu.tsx | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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

diff --git a/src/client/views/ContextMenu.tsx b/src/client/views/ContextMenu.tsx
index fcb934860..12352c667 100644
--- a/src/client/views/ContextMenu.tsx
+++ b/src/client/views/ContextMenu.tsx
@@ -44,8 +44,13 @@ export class ContextMenu extends React.Component {
 
     @action
     displayMenu(x: number, y: number) {
-        this._pageX = x
-        this._pageY = y
+        //maxX and maxY will change if the UI/font size changes, but will work for any amount
+        //of items added to the menu
+        let maxX = window.innerWidth - 150;
+        let maxY = window.innerHeight - (this._items.length * 34 + 30);
+
+        this._pageX = x > maxX ? maxX : x;
+        this._pageY = y > maxY ? maxY : y;
 
         this._searchString = "";
 
@@ -64,6 +69,7 @@ export class ContextMenu extends React.Component {
     }
 
     render() {
+
         return (
             <div className="contextMenu-cont" style={{ left: this._pageX, top: this._pageY, display: this._display }} ref={this.ref}>
                 <input className="contextMenu-item" type="text" placeholder="Search . . ." value={this._searchString} onChange={this.onChange}></input>
-- 
cgit v1.2.3-70-g09d2

