From f818303cb164b471805075226cba5451f35b27a2 Mon Sep 17 00:00:00 2001
From: anika-ahluwalia <anika.ahluwalia@gmail.com>
Date: Sun, 2 Aug 2020 17:33:38 -0500
Subject: fixing link bugs

---
 src/client/views/nodes/LinkDescriptionPopup.tsx | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

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

diff --git a/src/client/views/nodes/LinkDescriptionPopup.tsx b/src/client/views/nodes/LinkDescriptionPopup.tsx
index d8fe47f4e..720af6c9d 100644
--- a/src/client/views/nodes/LinkDescriptionPopup.tsx
+++ b/src/client/views/nodes/LinkDescriptionPopup.tsx
@@ -19,12 +19,15 @@ export class LinkDescriptionPopup extends React.Component<{}> {
 
     @action
     descriptionChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
-        LinkManager.currentLink && (LinkManager.currentLink.description = e.currentTarget.value);
+        this.description = e.currentTarget.value;
     }
 
     @action
-    onDismiss = () => {
+    onDismiss = (add: boolean) => {
         LinkDescriptionPopup.descriptionPopup = false;
+        if (add) {
+            LinkManager.currentLink && (LinkManager.currentLink.description = this.description);
+        }
     }
 
     @action
@@ -50,15 +53,16 @@ export class LinkDescriptionPopup extends React.Component<{}> {
                 left: LinkDescriptionPopup.popupX ? LinkDescriptionPopup.popupX : 700,
                 top: LinkDescriptionPopup.popupY ? LinkDescriptionPopup.popupY : 350,
             }}>
-            <input className="linkDescriptionPopup-input" onKeyPress={e => e.key === "Enter" && this.onDismiss()}
+            <input className="linkDescriptionPopup-input"
+                onKeyPress={e => e.key === "Enter" && this.onDismiss(true)}
                 placeholder={"(optional) enter link label..."}
                 onChange={(e) => this.descriptionChanged(e)}>
             </input>
             <div className="linkDescriptionPopup-btn">
                 <div className="linkDescriptionPopup-btn-dismiss"
-                    onPointerDown={this.onDismiss}> Dismiss </div>
+                    onPointerDown={e => this.onDismiss(false)}> Dismiss </div>
                 <div className="linkDescriptionPopup-btn-add"
-                    onPointerDown={this.onDismiss}> Add </div>
+                    onPointerDown={e => this.onDismiss(true)}> Add </div>
             </div>
         </div>;
     }
-- 
cgit v1.2.3-70-g09d2

