From 9d9c16939bb296a9deb38bc34cbea9870aee4f76 Mon Sep 17 00:00:00 2001
From: Sam Wilkins <samwilkins333@gmail.com>
Date: Tue, 9 Jul 2019 14:33:56 -0400
Subject: collection view fix

---
 src/client/views/nodes/KeyValueBox.tsx | 5 +++++
 1 file changed, 5 insertions(+)

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

diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index e8619584e..b5c47f138 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -175,7 +175,9 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
         if (!sourceDoc) {
             return;
         }
+
         let fieldTemplate = await this.inferType(sourceDoc[metaKey], metaKey);
+        let previousViewType = fieldTemplate.viewType;
 
         // move data doc fields to layout doc as needed (nativeWidth/nativeHeight, data, ??)
         let backgroundLayout = StrCast(fieldTemplate.backgroundLayout);
@@ -196,6 +198,7 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
         fieldTemplate.isTemplate = true;
         fieldTemplate.templates = new List<string>([Templates.TitleBar(metaKey)]);
         fieldTemplate.proto = Doc.GetProto(parentStackingDoc);
+        previousViewType && (fieldTemplate.viewType = previousViewType);
 
         Cast(parentStackingDoc.data, listSpec(Doc))!.push(fieldTemplate);
     }
@@ -214,8 +217,10 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
             }
             switch (first.type) {
                 case "image":
+                    console.log("STACKING VIEW CREATED for ", data);
                     return Docs.StackingDocument([], options);
                 case "text":
+                    console.log("TREE VIEW CREATED for ", data);
                     return Docs.TreeDocument([], options);
             }
         } else if (data instanceof ImageField) {
-- 
cgit v1.2.3-70-g09d2

