25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(grid): close cell details with Escape
二丫讲梵c511c90a7cb5
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vueindex 62d73b0d93..dade7eeaa8 100644--- a/apps/desktop/src/components/grid/DataGrid.vue+++ b/apps/desktop/src/components/grid/DataGrid.vue@@ -7365,6 +7365,23 @@ function closeCellDetails() {detailCell.value = null;}+function escapeCellDetails() {+ // Portalled overlays may keep focus in the grid. Let their own Escape handlers win.+ // Context menus close during capture, but remain mounted until Vue's next update.+ if (document.querySelector("[data-dbx-context-menu], [data-slot='dialog-content'][data-state='open'], [data-slot='popover-content'][data-state='open'], [data-slot='dropdown-menu-content'][data-state='open']")) return false;+ // Preserve the editors' existing Escape behavior even when a toolbar button has focus.+ if (isEditingDetail.value) {+ if (activeCellDetailTab.value === "valueEditor") {+ if (detailTemporalEditorConfig.value) cancelValueEditorEdit();+ else restoreDetailOriginalValue();+ } else cancelDetailEdit();+ return true;+ }+ closeCellDetails();+ nextTick(() => gridRef.value?.focus({ preventScroll: true }));+ return true;+}+function toggleMongoJsonPreview() {if (!canShowMongoJsonPreview.value) return;showMongoJsonPreview.value = !showMongoJsonPreview.value;@@ -9394,6 +9411,8 @@ function showCellDetails(rowIndex: number, colIndex: number) {activeCellDetailTab.value = defaultCellDetailTab();showCellDetail.value = true;hydrateCellDetailTarget(detailCell.value);+ // Move focus off the trigger so Escape can close the newly opened panel.+ gridRef.value?.focus({ preventScroll: true });}function showCellDetailsForVisibleCell(rowIndex: number, visibleColIdx: number, actualColIdx: number) {@@ -10833,6 +10852,15 @@ function cancelPendingRowOrRestoreCell(): boolean {async function onGridKeydown(event: KeyboardEvent) {if (event.defaultPrevented) return;+ const target = event.target;+ if (event.key === "Escape" && !event.isComposing && showCellDetail.value && target instanceof Element && (target === gridRef.value || target.closest("[data-cell-detail-panel]"))) {+ if (escapeCellDetails()) {+ event.preventDefault();+ event.stopPropagation();+ }+ return;+ }+if (isFocusWhereShortcut(event, settingsStore.editorSettings.shortcuts) && focusWhere()) {event.preventDefault();event.stopPropagation();@@ -15998,6 +16026,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val<!-- Cell Detail Drawer --><divv-if="showCellDetail && activeCellDetail"+ data-cell-detail-panelclass="relative flex flex-col bg-background min-w-0":class="[cellDetailPanelIsBottom ? 'col-start-1 row-start-2 border-t' : 'col-start-4 row-start-1 border-l', { 'detail-drawer-resizing': isResizingDetail }]":style="detailPanelStyle"@@ -16050,6 +16079,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val@copy-value="copyDetailCurrentValue"@commit="commitDetailEdit"@cancel="cancelDetailEdit"+ @close="escapeCellDetails"@save="onTemporalCellEditorSave"@set-null="setDetailNull"@copy-column-name="copyDetailColumnName"diff --git a/apps/desktop/src/components/grid/DataGridCellDetailDialog.vue b/apps/desktop/src/components/grid/DataGridCellDetailDialog.vueindex 91f4c289e2..76239f4f88 100644--- a/apps/desktop/src/components/grid/DataGridCellDetailDialog.vue+++ b/apps/desktop/src/components/grid/DataGridCellDetailDialog.vue@@ -102,6 +102,7 @@ watch(jsonPreviewContainer, async (element) => {jsonPreviewEditor = useCellDetailEditor({language: "json",readOnly: true,+ onEscape: () => (open.value = false),editorTheme: () => settingsStore.editorSettings.theme,appAppearance: () => (isDark.value ? "dark" : "light"),appPalette: () => themePalette.value,diff --git a/apps/desktop/src/components/grid/DataGridCellDetailHeader.vue b/apps/desktop/src/components/grid/DataGridCellDetailHeader.vueindex 93f46eb1b0..27c8d91dbd 100644--- a/apps/desktop/src/components/grid/DataGridCellDetailHeader.vue+++ b/apps/desktop/src/components/grid/DataGridCellDetailHeader.vue@@ -84,7 +84,7 @@ function toggleWordWrap() {<Button variant="ghost" size="icon" class="h-5 w-5" :title="t('grid.openColumnDetailsDialog')" @click="emit('openColumnDetails')"><TableProperties class="w-3 h-3" /></Button>- <Button variant="ghost" size="icon" class="h-5 w-5" @click="emit('close')">+ <Button variant="ghost" size="icon" class="h-5 w-5" :title="`${t('common.close')} (Esc)`" :aria-label="`${t('common.close')} (Esc)`" @click="emit('close')"><X class="w-3 h-3" /></Button></div>diff --git a/apps/desktop/src/components/grid/DataGridCellDetailPanel.vue b/apps/desktop/src/components/grid/DataGridCellDetailPanel.vueindex 323418d8e4..28be9008cc 100644--- a/apps/desktop/src/components/grid/DataGridCellDetailPanel.vue+++ b/apps/desktop/src/components/grid/DataGridCellDetailPanel.vue@@ -54,6 +54,7 @@ const emit = defineEmits<{copyValue: [];commit: [];cancel: [];+ close: [];save: [];setNull: [];copyColumnName: [];@@ -64,6 +65,7 @@ const { geometryPreviewOpen, geometryCanvas, detailsEditorContainer, sideJsonPredetail: toRef(props, "detail"),editValue: detailEditValue,onCancel: () => emit("cancel"),+ onClose: () => emit("close"),// 详情编辑器里按 Ctrl/Cmd+S 与 temporal 编辑器的 ctrl+s 路径保持一致:// 先 emit commit(把草稿落成待保存变更),再 emit save(触发网格保存)。onSave: () => {diff --git a/apps/desktop/src/composables/useDataGridCellDetail.ts b/apps/desktop/src/composables/useDataGridCellDetail.tsindex 08a5dc986c..86b0a3c6b4 100644--- a/apps/desktop/src/composables/useDataGridCellDetail.ts+++ b/apps/desktop/src/composables/useDataGridCellDetail.ts@@ -6,7 +6,7 @@ import { useSettingsStore } from "@/stores/settingsStore";import { renderWktOnCanvas } from "@/lib/dataGrid/geometryPreview";import type { DataGridCellDetail } from "@/lib/dataGrid/dataGridDetail";-export function useDataGridCellDetail(options: { detail: Ref<DataGridCellDetail>; editValue: Ref<string>; onCancel: () => void; onSave?: () => void }) {+export function useDataGridCellDetail(options: { detail: Ref<DataGridCellDetail>; editValue: Ref<string>; onCancel: () => void; onClose?: () => void; onSave?: () => void }) {const settingsStore = useSettingsStore();const { isDark, themePalette } = useTheme();const geometryPreviewOpen = ref(false);@@ -66,7 +66,7 @@ export function useDataGridCellDetail(options: { detail: Ref<DataGridCellDetail>watch(sideJsonPreviewContainer, async (element) => {if (element && !sideJsonEditor) {- const editor = useCellDetailEditor({ language: "json", readOnly: true, ...editorOptions() });+ const editor = useCellDetailEditor({ language: "json", readOnly: true, onEscape: options.onClose, ...editorOptions() });sideJsonEditor = editor;await editor.create(element, options.detail.value.formattedJson ?? "", "json");if (sideJsonEditor === editor) {