From 318a25826746a83d8d72ecfe6af650b46706a9c3 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 25 Jul 2022 09:37:27 -0400
Subject: fixed equationBox width sizing

---
 src/client/views/nodes/EquationBox.tsx | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(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 a714518cc..0bd30bce9 100644
--- a/src/client/views/nodes/EquationBox.tsx
+++ b/src/client/views/nodes/EquationBox.tsx
@@ -91,11 +91,21 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() {
         const scale = (this.props.NativeDimScaling?.() || 1) * NumCast(this.layoutDoc._viewScale, 1);
         return (
             <div
+                ref={r => {
+                    r instanceof HTMLDivElement &&
+                        new ResizeObserver(
+                            action((entries: any) => {
+                                if (entries[0].contentBoxSize[0].inlineSize) {
+                                    this.rootDoc._width = entries[0].contentBoxSize[0].inlineSize;
+                                }
+                            })
+                        ).observe(r);
+                }}
                 className="equationBox-cont"
                 onPointerDown={e => !e.ctrlKey && e.stopPropagation()}
                 style={{
                     transform: `scale(${scale})`,
-                    width: `${100 / scale}%`,
+                    width: 'fit-content', // `${100 / scale}%`,
                     height: `${100 / scale}%`,
                     pointerEvents: !this.props.isSelected() ? 'none' : undefined,
                 }}
-- 
cgit v1.2.3-70-g09d2

