LP#1775466 Dialog robustification
authorBill Erickson <berickxx@gmail.com>
Wed, 11 Jul 2018 18:55:55 +0000 (14:55 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Jul 2018 21:33:54 +0000 (17:33 -0400)
In certain circumstances, the close() operation can be called after the
dismiss() operation (blur action maybe?) which tries to invoke a method
on a now-null reference.  Avoid said invocation.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts

index 8a93ea6..3ffd5db 100644 (file)
@@ -56,7 +56,7 @@ export class DialogComponent implements OnInit {
                     this.modalRef = null;
                 },
                 (result) => {
-                    console.log('dialog closed with ' + result);
+                    console.debug('dialog closed with ' + result);
                     reject(result);
                     this.modalRef = null;
                 }
@@ -65,11 +65,15 @@ export class DialogComponent implements OnInit {
     }
 
     close(reason?: any): void {
-        this.modalRef.close(reason);
+        if (this.modalRef) {
+            this.modalRef.close(reason);
+        }
     }
 
     dismiss(reason?: any): void {
-        this.modalRef.dismiss(reason);
+        if (this.modalRef) {
+            this.modalRef.dismiss(reason);
+        }
     }
 }