From 33f9e8f4a599ef995ba8608e0f1be79c6ac37155 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Sun, 13 Mar 2022 22:59:00 +1100
Subject: Fix inconsistent-tileCount-on-layout-fail bug

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

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

diff --git a/src/components/TileTree.vue b/src/components/TileTree.vue
index ce3507d..d662f50 100644
--- a/src/components/TileTree.vue
+++ b/src/components/TileTree.vue
@@ -61,16 +61,20 @@ export default defineComponent({
 			nodeList[0].children = nodeList[0].tolNode.children.map((n: TolNode) => new LayoutNode(n, []));
 			layoutInfoHooks.updateLayoutInfoOnExpand(nodeList);
 			//try to re-layout
-			if (!this.tryLayout())
+			if (!this.tryLayout()){
 				nodeList[0].children = [];
+				layoutInfoHooks.updateLayoutInfoOnCollapse(nodeList);
+			}
 		},
 		onInnerHeaderClicked(nodeList: LayoutNode[]){
 			//nodeList is an array of layout-nodes, from the clicked-on-tile's node upward
 			let children = nodeList[0].children;
 			nodeList[0].children = [];
 			layoutInfoHooks.updateLayoutInfoOnCollapse(nodeList);
-			if (!this.tryLayout())
+			if (!this.tryLayout()){
 				nodeList[0].children = children;
+				layoutInfoHooks.updateLayoutInfoOnExpand(nodeList);
+			}
 		},
 		tryLayout(){
 			let newLayout = genLayout(this.layoutTree, [0,0], [this.width,this.height], true);
-- 
cgit v1.2.3

