From 4b4d77f99bd55e6de0593c3acd1cf5798ae038bf Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 10 May 2024 14:05:01 -0400
Subject: added an always option for OpenWhere lightbox.  cleaned up/fixed
 making collections capable of being a lightbox.

---
 .../collections/collectionFreeForm/CollectionFreeFormView.tsx | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

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

diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index dbd9fb11f..92e29e94a 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -42,7 +42,7 @@ import { DocumentView } from '../../nodes/DocumentView';
 import { FieldViewProps } from '../../nodes/FieldView';
 import { FocusViewOptions } from '../../nodes/FocusViewOptions';
 import { FormattedTextBox } from '../../nodes/formattedText/FormattedTextBox';
-import { OpenWhere } from '../../nodes/OpenWhere';
+import { OpenWhere, OpenWhereMod } from '../../nodes/OpenWhere';
 import { PinDocView, PinProps } from '../../PinFuncs';
 import { StyleProp } from '../../StyleProp';
 import { CollectionSubView } from '../CollectionSubView';
@@ -1066,9 +1066,10 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
             />
         );
     }
-    addDocTab = action((docsIn: Doc | Doc[], where: OpenWhere) => {
+    addDocTab = action((docsIn: Doc | Doc[], location: OpenWhere) => {
         const docs = toList(docsIn);
-        if (this._props.isAnnotationOverlay) return this._props.addDocTab(docs, where);
+        if (this._props.isAnnotationOverlay) return this._props.addDocTab(docs, location);
+        const where = location.split(':')[0];
         switch (where) {
             case OpenWhere.inParent:
                 return this._props.addDocument?.(docs) || false;
@@ -1095,13 +1096,13 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
                     }
                     if (firstDoc === this.Document || this.childDocList?.includes(firstDoc) || this.childLayoutPairs.map(pair => pair.layout)?.includes(firstDoc)) {
                         if (firstDoc.hidden) firstDoc.hidden = false;
-                        return true;
+                        if (!location.includes(OpenWhereMod.always)) return true;
                     }
                 }
                 break;
             default:
         }
-        return this._props.addDocTab(docs, where);
+        return this._props.addDocTab(docs, location);
     });
 
     getCalculatedPositions(pair: { layout: Doc; data?: Doc }): PoolData {
-- 
cgit v1.2.3-70-g09d2

