From 71ef0cc1ef0883316b2eb3afae9188dd12a42dfc Mon Sep 17 00:00:00 2001
From: anika-ahluwalia <anika.ahluwalia@gmail.com>
Date: Mon, 22 Jun 2020 16:58:31 -0500
Subject: tweaks to preview

---
 .../views/collections/CollectionSchemaCells.tsx    | 26 ++++++++++++----------
 1 file changed, 14 insertions(+), 12 deletions(-)

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

diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 7b76a5c84..6f43a2097 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -382,8 +382,6 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
     }
 
     onFocus = () => {
-
-        console.log(this._field);
         this._overlayDisposer?.();
         this._overlayDisposer = OverlayView.Instance.addElement(<DocumentIconContainer />, { x: 0, y: 0 });
     }
@@ -413,6 +411,16 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
         }
     }
 
+    @action
+    isEditingCalling = (isEditing: boolean): void => {
+        this.showPreview(false, "");
+        document.removeEventListener("keydown", this.onKeyDown);
+        isEditing && document.addEventListener("keydown", this.onKeyDown);
+        this._isEditing = isEditing;
+        this.props.setIsEditing(isEditing);
+        this.props.changeFocusedCellByIndex(this.props.row, this.props.col);
+    }
+
     onDown = (e: any) => {
         this.props.changeFocusedCellByIndex(this.props.row, this.props.col);
         this.props.setPreviewDoc(this.props.rowProps.original);
@@ -436,31 +444,24 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
     }
 
     render() {
-
-        const dragRef: React.RefObject<HTMLDivElement> = React.createRef();
-        const reference = React.createRef<HTMLDivElement>();
-
         if (typeof this._field === "object" && this._doc && this._docTitle) {
-
-
             return (
                 <div className="collectionSchemaView-cellWrapper" ref={this._focusRef} tabIndex={-1}
                     onPointerDown={(e) => { this.onDown(e); }}
-                    // onFocus={(e) => this.showPreview(true, e)}
                     onPointerEnter={(e) => { this.showPreview(true, e); }}
-                    // onBlur={(e) => { console.log("Blur"); this.showPreview(false, e) }}
                     onPointerLeave={(e) => { this.showPreview(false, e); }}
                 >
 
                     <div className="collectionSchemaView-cellContents-document"
                         style={{ padding: "5.9px" }}
-                        onFocus={this.onFocus} onBlur={() => this._overlayDisposer?.()}
                         ref={this.dropRef}
+                        onFocus={this.onFocus}
+                        onBlur={() => this._overlayDisposer?.()}
                     >
 
                         <EditableView
                             editing={this._isEditing}
-                            isEditingCallback={this.isEditingCallback}
+                            isEditingCallback={this.isEditingCalling}
                             display={"inline"}
                             contents={this._docTitle}
                             height={"auto"}
@@ -470,6 +471,7 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
                             }}
                             SetValue={action((value: string) => {
                                 this.onSetValue(value);
+                                this.showPreview(false, "");
                                 return true;
                             })}
                         />
-- 
cgit v1.2.3-70-g09d2

