Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: press ESC key to hide recent visited databases (#12056)

Liu Jib7941960cde9
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue
index ac1289c1c8..ccdb356662 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/SearchBox/index.vue
@@ -1,5 +1,6 @@
<template>
<NAutoComplete
+ ref="autoCompleteRef"
size="small"
clear-after-select
blur-after-select
@@ -11,6 +12,9 @@
:get-show="getOptionShow"
@update:value="$emit('update:search-pattern', $event || '')"
@select="handleDatabaseSelect"
+ @compositionstart="isIMECompositing = true"
+ @compositionend="isIMECompositing = false"
+ @keydown.esc="handleEscapeKey"
>
<template #prefix>
<SearchIcon class="w-4 h-auto text-gray-300" />
@@ -20,9 +24,9 @@
<script lang="ts" setup>
import { SearchIcon } from "lucide-vue-next";
-import type { SelectOption } from "naive-ui";
+import type { AutoCompleteInst, SelectOption } from "naive-ui";
import { NAutoComplete } from "naive-ui";
-import { computed, watchEffect, h } from "vue";
+import { computed, watchEffect, h, ref } from "vue";
import { useI18n } from "vue-i18n";
import { EnvironmentV1Name, InstanceV1EngineIcon } from "@/components/v2";
import { useDatabaseV1Store } from "@/store";
@@ -49,6 +53,8 @@ defineEmits<{
const { t } = useI18n();
const databaseStore = useDatabaseV1Store();
const { searchHistory } = useSearchHistory();
+const isIMECompositing = ref(false);
+const autoCompleteRef = ref<AutoCompleteInst>();
const getOptionShow = () => {
if (autoCompleteOptions.value[0].children.length === 0) {
@@ -134,6 +140,11 @@ const handleDatabaseSelect = (databaseName: string) => {
tryConnectToCoreSQLEditorTab(coreTab);
};
+const handleEscapeKey = (e: KeyboardEvent) => {
+ if (isIMECompositing.value) return;
+ autoCompleteRef.value?.blur();
+};
+
watchEffect(async () => {
for (const databaseName of searchHistory.value) {
const database = await databaseStore.getOrFetchDatabaseByName(
diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue
index fecb97b513..497d772733 100644
--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue
+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPanel.vue
@@ -1,6 +1,7 @@
<template>
<Drawer
:show="show"
+ :close-on-esc="false"
placement="left"
style="--n-body-padding: 4px 0"
@update:show="$emit('update:show', $event)"