aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/ContextMenu.tsx
diff options
context:
space:
mode:
authorHannah Chow <hannah_chow@brown.edu>2019-03-11 23:50:04 -0400
committerHannah Chow <hannah_chow@brown.edu>2019-03-11 23:50:04 -0400
commit888dd6f51befd156b24a3c60d56d8e5823e621ad (patch)
treeb6082a04695306357c379c0dcbffd0241e18d649 /src/client/views/ContextMenu.tsx
parente5c0eab1b3896cf28b6f54f5893d2998b70ef9af (diff)
parenta680579f74380eb016f0ffd61b3818d0850984b5 (diff)
origin merged
Diffstat (limited to 'src/client/views/ContextMenu.tsx')
-rw-r--r--src/client/views/ContextMenu.tsx11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/client/views/ContextMenu.tsx b/src/client/views/ContextMenu.tsx
index d68dc6e66..9109b56bb 100644
--- a/src/client/views/ContextMenu.tsx
+++ b/src/client/views/ContextMenu.tsx
@@ -46,11 +46,13 @@ export class ContextMenu extends React.Component {
@action
displayMenu(x: number, y: number) {
- this._pageX = x
- this._pageY = window.innerHeight - y >= 100 ? y : window.innerHeight - 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);
- // y pos absolute to top only when there's enough space
- this._yRelativeToTop = window.innerHeight - y >= 100;
+ this._pageX = x > maxX ? maxX : x;
+ this._pageY = y > maxY ? maxY : y;
this._searchString = "";
@@ -77,6 +79,7 @@ export class ContextMenu extends React.Component {
let style = this._yRelativeToTop ? { left: this._pageX, top: this._pageY, display: this._display } :
{ left: this._pageX, bottom: this._pageY, display: this._display };
+
return (
<div className="contextMenu-cont" style={style} ref={this.ref}>
<input className="contextMenu-item" type="text" placeholder="Search . . ." value={this._searchString} onChange={this.onChange}></input>