From 1b481cd441cc8bb200906b246b43e4bc5dc53b4e Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 2 Mar 2021 19:52:59 -0500
Subject: added a fitwidth toggle for lightbox.  fixed _showCaption/setting
 _fields to undefined.  updated documentView to use not having fitWidth set as
 a trigger for whether to treat a doc without nativeWidth/Height as if its
 width/height is that.

---
 src/client/views/nodes/EquationBox.tsx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

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

diff --git a/src/client/views/nodes/EquationBox.tsx b/src/client/views/nodes/EquationBox.tsx
index 7f9fc342a..5bc73d5d9 100644
--- a/src/client/views/nodes/EquationBox.tsx
+++ b/src/client/views/nodes/EquationBox.tsx
@@ -56,10 +56,13 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps, EquationDo
     }
     onChange = (str: string) => {
         this.dataDoc.text = str;
-        const _height = Number(getComputedStyle(this._ref.current!.element.current).height.replace("px", ""));
-        const _width = Number(getComputedStyle(this._ref.current!.element.current).width.replace("px", ""));
-        this.layoutDoc._width = Math.max(35, _width);
-        this.layoutDoc._height = Math.max(25, _height);
+        const style = this._ref.current && getComputedStyle(this._ref.current.element.current);
+        if (style) {
+            const _height = Number(style.height.replace("px", ""));
+            const _width = Number(style.width.replace("px", ""));
+            this.layoutDoc._width = Math.max(35, _width);
+            this.layoutDoc._height = Math.max(25, _height);
+        }
     }
     render() {
         TraceMobx();
-- 
cgit v1.2.3-70-g09d2

