From 65448167a4db396b2ee3c56d870233f8ac182eb6 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 11 Oct 2020 01:33:28 -0400
Subject: prevented documents that are unshared (ie private to soeone else)
 from showing up as an empty key value in stacking and other views. tried to
 fix an exception when showing links (that wasn't repeatable, so dion't know
 if fix works).

---
 .../CollectionFreeFormLinkView.tsx                 | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

(limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx')

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
index f051d5f8d..4cf257640 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
@@ -100,13 +100,15 @@ export class CollectionFreeFormLinkView extends React.Component<CollectionFreeFo
         let rect = el.getBoundingClientRect();
         const top = rect.top, height = rect.height;
         var el = el.parentNode;
-        do {
-            rect = el.getBoundingClientRect();
-            if (top <= rect.bottom === false && getComputedStyle(el).overflow === "hidden") return rect.bottom;
-            // Check if the element is out of view due to a container scrolling
-            if ((top + height) <= rect.top && getComputedStyle(el).overflow === "hidden") return rect.top;
+        while (el && el !== document.body) {
+            if (el.hasOwnProperty("getBoundingClientRect")) {
+                rect = el.getBoundingClientRect();
+                if (top <= rect.bottom === false && getComputedStyle(el).overflow === "hidden") return rect.bottom;
+                // Check if the element is out of view due to a container scrolling
+                if ((top + height) <= rect.top && getComputedStyle(el).overflow === "hidden") return rect.top;
+            }
             el = el.parentNode;
-        } while (el !== document.body);
+        }
         // Check its within the document viewport
         return top; //top <= document.documentElement.clientHeight && getComputedStyle(document.documentElement).overflow === "hidden";
     }
@@ -114,13 +116,15 @@ export class CollectionFreeFormLinkView extends React.Component<CollectionFreeFo
         let rect = el.getBoundingClientRect();
         const left = rect.left, width = rect.width;
         var el = el.parentNode;
-        do {
-            rect = el.getBoundingClientRect();
-            if (left <= rect.right === false && getComputedStyle(el).overflow === "hidden") return rect.right;
-            // Check if the element is out of view due to a container scrolling
-            if ((left + width) <= rect.left && getComputedStyle(el).overflow === "hidden") return rect.left;
+        while (el && el !== document.body) {
+            if (el.hasOwnProperty("getBoundingClientRect")) {
+                rect = el.getBoundingClientRect();
+                if (left <= rect.right === false && getComputedStyle(el).overflow === "hidden") return rect.right;
+                // Check if the element is out of view due to a container scrolling
+                if ((left + width) <= rect.left && getComputedStyle(el).overflow === "hidden") return rect.left;
+            }
             el = el.parentNode;
-        } while (el !== document.body);
+        }
         // Check its within the document viewport
         return left; //top <= document.documentElement.clientHeight && getComputedStyle(document.documentElement).overflow === "hidden";
     }
-- 
cgit v1.2.3-70-g09d2

