From 222bb987a43a9e9d53e8860b18a8836b431afe47 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Mon, 18 Jul 2022 15:28:39 +0200 Subject: [PATCH] chore(CommandPalette): improve component --- src/runtime/components/navigation/CommandPalette.vue | 12 +++++++----- src/runtime/types/command-palette.d.ts | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/runtime/components/navigation/CommandPalette.vue b/src/runtime/components/navigation/CommandPalette.vue index fb4eb264..a8210084 100644 --- a/src/runtime/components/navigation/CommandPalette.vue +++ b/src/runtime/components/navigation/CommandPalette.vue @@ -20,7 +20,7 @@ - + @@ -126,7 +126,7 @@ function activateFirstOption () { }, 0) } -function onSelect (option) { +function onSelect (option: Command) { if (option.disabled) { return } @@ -140,9 +140,11 @@ function onSelect (option) { emit('update:modelValue', option) // waiting for modal to be closed - setTimeout(() => { - query.value = '' - }, 300) + if (!option.prevent) { + setTimeout(() => { + query.value = '' + }, 300) + } } function onClear () { diff --git a/src/runtime/types/command-palette.d.ts b/src/runtime/types/command-palette.d.ts index 00fd87aa..a3474d83 100644 --- a/src/runtime/types/command-palette.d.ts +++ b/src/runtime/types/command-palette.d.ts @@ -1,4 +1,5 @@ import type { UseFuseOptions } from '@vueuse/integrations/useFuse' +import type { RouteLocationRaw } from 'vue-router' export interface Command { prefix?: string @@ -9,6 +10,9 @@ export interface Command { avatar?: string chip?: string disabled?: boolean + prevent?: boolean + click?: Function + to?: RouteLocationRaw shortcuts?: string[] }