From 91f78e4ec12eda07840b940692013a1aa025b7b8 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Sat, 26 Mar 2022 11:58:28 +1100
Subject: Make search account for hidden nodes

---
 src/components/TileTree.vue | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

(limited to 'src/components/TileTree.vue')

diff --git a/src/components/TileTree.vue b/src/components/TileTree.vue
index 0285505..4ede92f 100644
--- a/src/components/TileTree.vue
+++ b/src/components/TileTree.vue
@@ -271,23 +271,34 @@ export default defineComponent({
 		},
 		expandToTolNode(tolNode: TolNode){
 			// Check if searched node is shown
-			if (this.layoutMap.get(tolNode.name) != null){
+			let layoutNode = this.layoutMap.get(tolNode.name);
+			if (layoutNode != null && !layoutNode.hidden){
 				return;
 			}
-			// Get ancestor to expand
-			let ancestor = tolNode.parent!;
+			// Get nearest in-layout-tree ancestor
+			let ancestor = tolNode;
 			while (this.layoutMap.get(ancestor.name) == null){
 				ancestor = ancestor.parent!;
 			}
-			// Attempt expansion
-			let layoutNode = this.layoutMap.get(ancestor.name)!;
+			layoutNode = this.layoutMap.get(ancestor.name)!;
+			// If hidden, expand ancestor in parent-bar
+			if (layoutNode.hidden){
+				// Get ancestor in parent-bar
+				while (!this.sepdParents.includes(layoutNode)){
+					ancestor = ancestor.parent;
+					layoutNode = this.layoutMap.get(ancestor.name);
+				}
+				this.onSepdParentClicked(layoutNode);
+				setTimeout(() => this.expandToTolNode(tolNode), 300);
+				return;
+			}
+			// Attempt tile-expand
 			let success = this.onInnerLeafClicked({layoutNode});
 			if (success){
-				console.log('Expanded ' + ancestor.name);
 				setTimeout(() => this.expandToTolNode(tolNode), 300);
 				return;
 			}
-			// Expand-to-view an ancestor just below the activeRoot
+			// Attempt expand-to-view on ancestor just below activeRoot
 			if (ancestor.name == this.activeRoot.tolNode.name){
 				console.log('Unable to complete search (not enough room to expand active root)');
 					// Happens if screen is very small or node has very many children
@@ -301,7 +312,6 @@ export default defineComponent({
 			}
 			layoutNode = this.layoutMap.get(ancestor.name)!;
 			this.onInnerHeaderClickHeld(layoutNode);
-			console.log('Expanded-to-view ' + ancestor.name);
 			setTimeout(() => this.expandToTolNode(tolNode), 300);
 		},
 	},
-- 
cgit v1.2.3

