From 40971c01df7063073dfe3a5240da5053e094b45d Mon Sep 17 00:00:00 2001
From: anika-ahluwalia <anika.ahluwalia@gmail.com>
Date: Wed, 19 Aug 2020 00:25:15 -0500
Subject: fixed link label cut off

---
 src/client/views/nodes/DocumentLinksButton.tsx | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

(limited to 'src/client/views/nodes/DocumentLinksButton.tsx')

diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx
index cf8645e4c..70e7d8311 100644
--- a/src/client/views/nodes/DocumentLinksButton.tsx
+++ b/src/client/views/nodes/DocumentLinksButton.tsx
@@ -129,9 +129,15 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp
                             LinkDescriptionPopup.popupY = e.screenY - 100;
                             LinkDescriptionPopup.descriptionPopup = true;
 
-                            LinkDescriptionPopup.popupX = e.screenX;
-                            LinkDescriptionPopup.popupY = e.screenY - 100;
-                            LinkDescriptionPopup.descriptionPopup = true;
+                            const rect = document.body.getBoundingClientRect();
+                            if (LinkDescriptionPopup.popupX + 200 > rect.width) {
+                                LinkDescriptionPopup.popupX -= 190;
+                                TaskCompletionBox.popupX -= 40;
+                            }
+                            if (LinkDescriptionPopup.popupY + 100 > rect.height) {
+                                LinkDescriptionPopup.popupY -= 40;
+                                TaskCompletionBox.popupY -= 40;
+                            }
 
                             setTimeout(action(() => TaskCompletionBox.taskCompleted = false), 2500);
                         }
@@ -176,6 +182,17 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp
                     LinkDescriptionPopup.popupY = screenY - 100;
                     LinkDescriptionPopup.descriptionPopup = true;
                 }
+
+                const rect = document.body.getBoundingClientRect();
+                if (LinkDescriptionPopup.popupX + 200 > rect.width) {
+                    LinkDescriptionPopup.popupX -= 190;
+                    TaskCompletionBox.popupX -= 40;
+                }
+                if (LinkDescriptionPopup.popupY + 100 > rect.height) {
+                    LinkDescriptionPopup.popupY -= 40;
+                    TaskCompletionBox.popupY -= 40;
+                }
+
                 setTimeout(action(() => { TaskCompletionBox.taskCompleted = false; }), 2500);
             }
         }
-- 
cgit v1.2.3-70-g09d2

