From ec4c5337186723e6d0471e3ca03d411fdfa7af4e Mon Sep 17 00:00:00 2001
From: Corentin Thomasset <corentin.thomasset74@gmail.com>
Date: Mon, 19 Jun 2023 21:51:25 +0200
Subject: feat(command-palette): random tool action

---
 src/modules/command-palette/command-palette.vue | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

(limited to 'src/modules/command-palette/command-palette.vue')

diff --git a/src/modules/command-palette/command-palette.vue b/src/modules/command-palette/command-palette.vue
index bd431a0..12ad5fb 100644
--- a/src/modules/command-palette/command-palette.vue
+++ b/src/modules/command-palette/command-palette.vue
@@ -76,19 +76,35 @@ function getOptionIndex(option: PaletteOption) {
 }
 
 function activateOption(option: PaletteOption) {
+  const { closeOnSelect } = option;
+
   if (option.action) {
     option.action();
+
+    if (closeOnSelect) {
+      close();
+    }
+
     return;
   }
 
+  const closeAfterNavigation = closeOnSelect || _.isUndefined(closeOnSelect);
+
   if (option.to) {
     router.push(option.to);
-    close();
+
+    if (closeAfterNavigation) {
+      close();
+    }
+    return;
   }
 
   if (option.href) {
     window.open(option.href, '_blank');
-    close();
+
+    if (closeAfterNavigation) {
+      close();
+    }
   }
 }
 </script>
-- 
cgit v1.2.3

