From 8049464ee4f67a8eb5794346804290875463e48f Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 13 Jul 2023 10:52:27 -0400
Subject: fixes for equation box default selections.

---
 src/client/views/nodes/EquationBox.tsx | 7 ++++---
 1 file changed, 4 insertions(+), 3 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 8d45c5724..a77e4bdd1 100644
--- a/src/client/views/nodes/EquationBox.tsx
+++ b/src/client/views/nodes/EquationBox.tsx
@@ -26,7 +26,8 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() {
             this.props.select(false);
 
             this._ref.current!.mathField.focus();
-            this._ref.current!.mathField.select();
+            this.rootDoc.text === 'x' && this._ref.current!.mathField.select();
+            EquationBox.SelectOnLoad = '';
         }
         reaction(
             () => StrCast(this.dataDoc.text),
@@ -35,6 +36,7 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() {
                     this._ref.current!.mathField.latex(text);
                 }
             }
+            //{ fireImmediately: true }
         );
         reaction(
             () => this.props.isSelected(),
@@ -53,9 +55,8 @@ export class EquationBox extends ViewBoxBaseComponent<FieldViewProps>() {
         const _height = Number(getComputedStyle(this._ref.current!.element.current).height.replace('px', ''));
         const _width = Number(getComputedStyle(this._ref.current!.element.current).width.replace('px', ''));
         if (e.key === 'Enter') {
-            const nextEq = Docs.Create.EquationDocument({
+            const nextEq = Docs.Create.EquationDocument(e.shiftKey ? StrCast(this.dataDoc.text) : 'x', {
                 title: '# math',
-                text: StrCast(this.dataDoc.text),
                 _width,
                 _height: 25,
                 x: NumCast(this.layoutDoc.x),
-- 
cgit v1.2.3-70-g09d2

