From c0eed7dae87cdbed392699f9b400c8659a5188ca Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 21 Feb 2024 16:16:39 -0500
Subject: got rid of dropdown for fieldValue views of a tag since tags have no
 values. fixed populating collection with tag docs to not create duplicates.

---
 src/client/views/nodes/DocumentView.tsx | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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

diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 73c13b5dd..e8b0fc4ba 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -1500,7 +1500,8 @@ ScriptingGlobals.add(function updateTagsCollection(collection: Doc) {
     let created = false;
     const matchedDocs = matchedTags
         .filter(tagDoc => !Doc.AreProtosEqual(collection, tagDoc))
-        .map(tagDoc => {
+        .reduce((aset, tagDoc) => {
+            if (Array.from(aset).find(doc => Doc.AreProtosEqual(tagDoc, doc))) return aset;
             let embedding = collectionDocs.find(doc => Doc.AreProtosEqual(tagDoc, doc));
             if (!embedding) {
                 embedding = Doc.MakeEmbedding(tagDoc);
@@ -1510,9 +1511,10 @@ ScriptingGlobals.add(function updateTagsCollection(collection: Doc) {
                 wid += NumCast(tagDoc._width);
                 created = true;
             }
-            return embedding;
-        });
+            aset.add(embedding);
+            return aset;
+        }, new Set<Doc>());
 
-    created && (collection[DocData].data = new List<Doc>(matchedDocs));
+    created && (collection[DocData].data = new List<Doc>(Array.from(matchedDocs)));
     return true;
 });
-- 
cgit v1.2.3-70-g09d2


From cf85ee4ea73985529a16321d671d893ddb862439 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 22 Feb 2024 09:33:38 -0500
Subject: fixed search to update after typing delay. fixed collection of tags
 to set container for embeddings

---
 src/client/views/nodes/DocumentView.tsx |  4 ++--
 src/client/views/search/SearchBox.tsx   | 10 +++++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

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

diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index e8b0fc4ba..d131f72d5 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -1501,8 +1501,7 @@ ScriptingGlobals.add(function updateTagsCollection(collection: Doc) {
     const matchedDocs = matchedTags
         .filter(tagDoc => !Doc.AreProtosEqual(collection, tagDoc))
         .reduce((aset, tagDoc) => {
-            if (Array.from(aset).find(doc => Doc.AreProtosEqual(tagDoc, doc))) return aset;
-            let embedding = collectionDocs.find(doc => Doc.AreProtosEqual(tagDoc, doc));
+            let embedding = Array.from(aset).find(doc => Doc.AreProtosEqual(tagDoc, doc)) ?? collectionDocs.find(doc => Doc.AreProtosEqual(tagDoc, doc));
             if (!embedding) {
                 embedding = Doc.MakeEmbedding(tagDoc);
                 embedding.x = wid;
@@ -1511,6 +1510,7 @@ ScriptingGlobals.add(function updateTagsCollection(collection: Doc) {
                 wid += NumCast(tagDoc._width);
                 created = true;
             }
+            Doc.SetContainer(embedding, collection);
             aset.add(embedding);
             return aset;
         }, new Set<Doc>());
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 0b664beaa..9f153e86d 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -88,9 +88,11 @@ export class SearchBox extends ViewBoxBaseComponent<SearchBoxProps>() {
      * (Note: There is no longer a need to press enter to submit a search. Any update to the input
      * causes a search to be submitted automatically.)
      */
+    _timeout: any = undefined;
     onInputChange = action((e: React.ChangeEvent<HTMLInputElement>) => {
         this._searchString = e.target.value;
-        this.submitSearch();
+        this._timeout && clearTimeout(this._timeout);
+        this._timeout = setTimeout(() => this.submitSearch(), 300);
     });
 
     /**
@@ -334,6 +336,8 @@ export class SearchBox extends ViewBoxBaseComponent<SearchBoxProps>() {
      * brushes and highlights. All search matches are cleared as well.
      */
     resetSearch = action(() => {
+        this._timeout && clearTimeout(this._timeout);
+        this._timeout = undefined;
         this._results.forEach((_, doc) => {
             DocumentManager.Instance.getFirstDocumentView(doc)?.ComponentView?.search?.('', undefined, true);
             Doc.UnBrushDoc(doc);
@@ -436,10 +440,10 @@ export class SearchBox extends ViewBoxBaseComponent<SearchBoxProps>() {
                         </select>
                     )}
                     <input
-                        defaultValue={''}
+                        defaultValue=""
                         autoComplete="off"
                         onChange={this.onInputChange}
-                        onKeyPress={e => {
+                        onKeyDown={e => {
                             e.key === 'Enter' ? this.submitSearch() : null;
                             e.stopPropagation();
                         }}
-- 
cgit v1.2.3-70-g09d2

