From 655faf508dd9c1d811fbd4ca325a41aa5da4f0b3 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Fri, 25 Mar 2022 15:09:02 +1100
Subject: Allow interaction with settings open. Add esc shortcut.

---
 src/components/TileTree.vue | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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

diff --git a/src/components/TileTree.vue b/src/components/TileTree.vue
index fba5863..10a437d 100644
--- a/src/components/TileTree.vue
+++ b/src/components/TileTree.vue
@@ -210,7 +210,6 @@ export default defineComponent({
 		//
 		onSettingsOpen(){
 			this.settingsOpen = true;
-			this.infoModalNode = null;
 		},
 		onSettingsClose(){
 			this.settingsOpen = false;
@@ -218,13 +217,25 @@ export default defineComponent({
 		onLayoutOptionChange(){
 			tryLayout(this.activeRoot, this.tileAreaPos, this.tileAreaDims, this.layoutOptions, true);
 		},
+		onKeyUp(evt: KeyboardEvent){
+			if (evt.key == 'Escape'){
+				if (this.settingsOpen){
+					this.settingsOpen = false;
+				}
+				if (this.infoModalNode != null){
+					this.infoModalNode = null;
+				}
+			}
+		},
 	},
 	created(){
 		window.addEventListener('resize', this.onResize);
+		window.addEventListener('keyup', this.onKeyUp);
 		tryLayout(this.activeRoot, this.tileAreaPos, this.tileAreaDims, this.layoutOptions, true);
 	},
 	unmounted(){
 		window.removeEventListener('resize', this.onResize);
+		window.removeEventListener('keyup', this.onKeyUp);
 	},
 	components: {Tile, ParentBar, TileInfoModal, Settings, },
 });
-- 
cgit v1.2.3

