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
fix(grid): commit and save temporal cell edits on Ctrl+S
zipgcf615f6d15e7
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vueindex 32d0e244de..c1efe75ec7 100644--- a/apps/desktop/src/components/grid/DataGrid.vue+++ b/apps/desktop/src/components/grid/DataGrid.vue@@ -9375,6 +9375,14 @@ async function saveGridChangesFromShortcut() {return true;}+/// datetime/date/time 单元格编辑器会吃掉自身按键,保存快捷键由它转发成 save 事件后在这里补上保存(#10515)。+async function onTemporalCellEditorSave() {+ await nextTick();+ if (await saveGridChangesFromShortcut()) {+ gridRef.value?.focus({ preventScroll: true });+ }+}+async function onCellEditKeydown(event: KeyboardEvent) {if (isSaveShortcut(event, settingsStore.editorSettings.shortcuts)) {event.preventDefault();@@ -12870,6 +12878,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.valcell-layout="transpose"@cancel="cancelEdit"@commit="commitGridEdit"+ @save="onTemporalCellEditorSave"/><EnumCellEditorv-else-if="isBooleanGridCell(displayItems[cell.recordIndex], cell.valueIndex)"@@ -13562,6 +13571,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val:normalize-value="(value) => normalizeTemporalCellEditorValue(value, canvasEditingCell!.actualColIdx)"@cancel="cancelEdit"@commit="commitGridEdit"+ @save="onTemporalCellEditorSave"/><EnumCellEditorv-else-if="isBooleanGridCell(getRowItem(canvasEditingCell.rowId), canvasEditingCell.actualColIdx)"@@ -13782,6 +13792,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val:normalize-value="(value) => normalizeTemporalCellEditorValue(value, col.actualColIdx)"@cancel="cancelEdit"@commit="commitGridEdit"+ @save="onTemporalCellEditorSave"/><EnumCellEditorv-else-if="isBooleanGridCell(item, col.actualColIdx)"@@ -14129,6 +14140,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val@copy-value="copyDetailCurrentValue"@commit="commitDetailEdit"@cancel="cancelDetailEdit"+ @save="onTemporalCellEditorSave"@set-null="setDetailNull"@copy-column-name="copyDetailColumnName"@copy-sql-condition="copyDetailSqlCondition"@@ -14146,6 +14158,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val:commit-on-close="false"@cancel="cancelValueEditorEdit"@commit="commitValueEditorEdit"+ @save="onTemporalCellEditorSave"/><div v-else ref="valueEditorContainer" data-cell-detail-editor-root class="min-h-0 min-w-0 flex-1 w-full rounded border overflow-auto" /></div>diff --git a/apps/desktop/src/components/grid/DataGridCellDetailPanel.vue b/apps/desktop/src/components/grid/DataGridCellDetailPanel.vueindex a054e8317e..43038b851d 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: [];+ save: [];setNull: [];copyColumnName: [];copySqlCondition: [];@@ -183,7 +184,7 @@ defineExpose({ openSearch });</div><template v-if="editing"><div class="dbx-data-grid-value-font min-h-0 min-w-0 flex-1" :style="editorStyle">- <TemporalCellEditor v-if="temporalEditorConfig" v-model="detailEditValue" :kind="temporalEditorConfig.kind" :fraction-precision="temporalEditorConfig.fractionPrecision" variant="inline" :commit-on-close="false" @cancel="emit('cancel')" @commit="emit('commit')" />+ <TemporalCellEditor v-if="temporalEditorConfig" v-model="detailEditValue" :kind="temporalEditorConfig.kind" :fraction-precision="temporalEditorConfig.fractionPrecision" variant="inline" :commit-on-close="false" @cancel="emit('cancel')" @commit="emit('commit')" @save="emit('save')" /><div v-else ref="detailsEditorContainer" data-cell-detail-editor-root class="min-h-0 h-full w-full rounded border overflow-hidden" /></div><div v-if="!panelIsBottom" class="flex shrink-0 gap-1 py-0.5">diff --git a/apps/desktop/src/components/grid/TemporalCellEditor.vue b/apps/desktop/src/components/grid/TemporalCellEditor.vueindex d0cdbcb91c..ec17ff472d 100644--- a/apps/desktop/src/components/grid/TemporalCellEditor.vue+++ b/apps/desktop/src/components/grid/TemporalCellEditor.vue@@ -3,9 +3,13 @@ import { computed, nextTick, onMounted, ref, watch } from "vue";import type { FocusOutsideEvent, PointerDownOutsideEvent } from "reka-ui";import { CalendarClock, ChevronDown, ChevronUp, CircleSlash } from "@lucide/vue";import { Button } from "@/components/ui/button";+import { isSaveShortcut } from "@/lib/editor/keyboardShortcuts";+import { useSettingsStore } from "@/stores/settingsStore";import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "@/components/ui/popover";import { formatTemporalInputValue, hostTimezoneOffsetSuffix, parseTemporalInputValue, stepTemporalInputValue, temporalOffsetSuffix, type TemporalCellEditorKind } from "@/lib/dataGrid/dataGridTemporalEditor";+const settingsStore = useSettingsStore();+const props = withDefaults(defineProps<{kind: TemporalCellEditorKind;@@ -28,6 +32,7 @@ const emit = defineEmits<{"update:modelValue": [value: string];commit: [];cancel: [];+ save: [];}>();const open = ref(false);@@ -216,6 +221,15 @@ function finishCancel() {}function onKeydown(event: KeyboardEvent) {+ // 编辑器的 keydown 一律 stop 掉,因此网格上的保存快捷键不会冒泡过去;+ // 这里必须自己识别并转发,否则 datetime/date/time 单元格编辑期间按 Ctrl/Cmd+S 会被静默丢弃。+ if (isSaveShortcut(event, settingsStore.editorSettings.shortcuts)) {+ event.preventDefault();+ flushInputValue(event.target);+ finishCommit();+ emit("save");+ return;+ }if (event.key === "Enter") {event.preventDefault();flushInputValue(event.target);diff --git a/apps/desktop/src/components/grid/__tests__/TemporalCellEditorSaveShortcut.spec.ts b/apps/desktop/src/components/grid/__tests__/TemporalCellEditorSaveShortcut.spec.tsnew file mode 100644index 0000000000..cb3c16d555--- /dev/null+++ b/apps/desktop/src/components/grid/__tests__/TemporalCellEditorSaveShortcut.spec.ts@@ -0,0 +1,102 @@+// @vitest-environment happy-dom++import { readFileSync } from "node:fs";+import { resolve } from "node:path";+import { createApp, defineComponent, h, ref, type App } from "vue";+import { createPinia, setActivePinia } from "pinia";+import { afterEach, describe, expect, it, vi } from "vitest";++import TemporalCellEditor from "../TemporalCellEditor.vue";++const dataGridSource = readFileSync(resolve(import.meta.dirname, "../DataGrid.vue"), "utf8");+const cellDetailPanelSource = readFileSync(resolve(import.meta.dirname, "../DataGridCellDetailPanel.vue"), "utf8");++const dataGridTemporalEditors = dataGridSource.match(/<TemporalCellEditor\b[\s\S]*?\/>/g) ?? [];++const mountedApps: Array<{ app: App; host: HTMLElement }> = [];++function mountEditor() {+ const pinia = createPinia();+ setActivePinia(pinia);+ const modelValue = ref("2026-01-02 03:04:05");+ const onCommit = vi.fn();+ const onCancel = vi.fn();+ const onSave = vi.fn();+ const host = document.createElement("div");+ document.body.append(host);+ const Root = defineComponent({+ setup() {+ return () =>+ h(TemporalCellEditor, {+ kind: "datetime",+ modelValue: modelValue.value,+ "onUpdate:modelValue": (value: string) => {+ modelValue.value = value;+ },+ onCommit,+ onCancel,+ onSave,+ });+ },+ });+ const app = createApp(Root);+ app.use(pinia);+ app.mount(host);+ mountedApps.push({ app, host });+ const input = host.querySelector("input");+ if (!input) throw new Error("Temporal editor input not found");+ return { host, input, modelValue, onCommit, onCancel, onSave };+}++function keydown(target: HTMLInputElement, init: KeyboardEventInit): KeyboardEvent {+ const event = new KeyboardEvent("keydown", { bubbles: true, cancelable: true, ...init });+ target.dispatchEvent(event);+ return event;+}++afterEach(() => {+ for (const { app, host } of mountedApps.splice(0)) {+ app.unmount();+ host.remove();+ }+});++describe("TemporalCellEditor save shortcut", () => {+ it("forwards Ctrl/Cmd+S to the grid instead of dropping it (#10515)", () => {+ const { input, onCommit, onCancel, onSave, modelValue } = mountEditor();++ input.value = "2026-03-04 05:06:07";+ input.dispatchEvent(new Event("input"));+ const event = keydown(input, { key: "s", ctrlKey: true });++ expect(event.defaultPrevented).toBe(true);+ expect(modelValue.value).toBe("2026-03-04 05:06:07");+ expect(onCommit).toHaveBeenCalledOnce();+ expect(onSave).toHaveBeenCalledOnce();+ expect(onCancel).not.toHaveBeenCalled();+ });++ it("keeps the existing Enter commit and Escape cancel behaviour", () => {+ const enterCase = mountEditor();+ const enter = keydown(enterCase.input, { key: "Enter" });+ expect(enter.defaultPrevented).toBe(true);+ expect(enterCase.onCommit).toHaveBeenCalledOnce();+ expect(enterCase.onSave).not.toHaveBeenCalled();++ const escapeCase = mountEditor();+ const escape = keydown(escapeCase.input, { key: "Escape" });+ expect(escape.defaultPrevented).toBe(true);+ expect(escapeCase.onCancel).toHaveBeenCalledOnce();+ expect(escapeCase.onCommit).not.toHaveBeenCalled();+ expect(escapeCase.onSave).not.toHaveBeenCalled();+ });++ it("binds the forwarded save event on every grid temporal editor", () => {+ expect(dataGridTemporalEditors.length).toBeGreaterThan(0);+ for (const editor of dataGridTemporalEditors) {+ expect(editor).toContain('@save="onTemporalCellEditorSave"');+ }+ expect(cellDetailPanelSource).toContain("@save=\"emit('save')\"");+ expect(dataGridSource).toMatch(/onTemporalCellEditorSave\(\)[\s\S]*?saveGridChangesFromShortcut\(\)/);+ });+});