From 44d25c8beb0d00f72a837fcf34c891f1473671f0 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Mon, 20 Jun 2022 00:39:21 +1000
Subject: Avoid creating certain redundant dom-nodes after layout-with-collapse

---
 src/App.vue | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

(limited to 'src/App.vue')

diff --git a/src/App.vue b/src/App.vue
index 9b39759..3d9b340 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -300,17 +300,20 @@ export default defineComponent({
 			this.activeRoot = layoutNode;
 			this.updateAreaDims().then(() => this.relayoutWithCollapse());
 		},
-		onDetachedAncestorClick(layoutNode: LayoutNode, skipRelayout = false){
+		onDetachedAncestorClick(layoutNode: LayoutNode, alsoCollapse = false){
 			if (!this.handleActionForTutorial('unhideAncestor')){
 				return;
 			}
 			this.setLastFocused(null);
-			LayoutNode.showDownward(layoutNode);
 			this.activeRoot = layoutNode;
 			this.overflownRoot = false;
-			if (!skipRelayout){
-				this.updateAreaDims().then(() => this.relayoutWithCollapse());
+			if (alsoCollapse){
+				this.onNonleafClick(layoutNode, true);
 			}
+			return this.updateAreaDims().then(() => {
+				this.relayoutWithCollapse();
+				LayoutNode.showDownward(layoutNode);
+			});
 		},
 		// For tile-info events
 		onInfoIconClick(nodeName: string){
@@ -374,9 +377,8 @@ export default defineComponent({
 					this.onDetachedAncestorClick(nodeInAncestryBar!);
 					setTimeout(() => this.expandToNode(name), this.uiOpts.tileChgDuration);
 				} else{
-					this.onDetachedAncestorClick(nodeInAncestryBar, true);
-					this.onNonleafClick(nodeInAncestryBar, true);
-					this.expandToNode(name);
+					this.onDetachedAncestorClick(nodeInAncestryBar, true)
+						.then(() => this.expandToNode(name));
 				}
 				return;
 			}
-- 
cgit v1.2.3

