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): use native context menu in filter inputs
jearhef9c4b19a6008
diff --git a/apps/desktop/src/components/grid/DataGridConditionEditor.vue b/apps/desktop/src/components/grid/DataGridConditionEditor.vueindex 2d33a80acc..0b3526ef08 100644--- a/apps/desktop/src/components/grid/DataGridConditionEditor.vue+++ b/apps/desktop/src/components/grid/DataGridConditionEditor.vue@@ -528,6 +528,7 @@ defineExpose({ focus, dismiss: editor.dismiss, rememberHistory: editor.rememberH@compositionstart="onCompositionStart"@compositionend="onCompositionEnd"@input="onInput"+ @contextmenu.stop@keydown="onKeydown"/></div>@@ -562,6 +563,7 @@ defineExpose({ focus, dismiss: editor.dismiss, rememberHistory: editor.rememberH@compositionstart="onCompositionStart"@compositionend="onCompositionEnd"@input="onInput"+ @contextmenu.stop@keydown="onKeydown"/><div class="data-grid-topbar-condition-floating-controls pointer-events-none absolute inset-x-2 z-[2] flex h-6 min-w-0 items-center gap-1">diff --git a/apps/desktop/src/components/grid/__tests__/DataGridContextExtractor.spec.ts b/apps/desktop/src/components/grid/__tests__/DataGridContextExtractor.spec.tsindex 338b3647e9..58847304e8 100644--- a/apps/desktop/src/components/grid/__tests__/DataGridContextExtractor.spec.ts+++ b/apps/desktop/src/components/grid/__tests__/DataGridContextExtractor.spec.ts@@ -295,6 +295,77 @@ describe("DataGrid context menu target lifecycle", () => {expect(contextMenuLabels()).toContain("Freeze Selected Columns");});+ it.each(["WHERE", "ORDER BY"] as const)("keeps the native context menu for the %s condition editor", async (placeholder) => {+ const { host } = mountGrid(hydratedResult(1, "value"));+ await settle();++ const input = host.querySelector<HTMLTextAreaElement>(`textarea[placeholder="${placeholder}"]`);+ expect(input).not.toBeNull();++ const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 });+ input!.dispatchEvent(event);+ await settle();++ expect(event.defaultPrevented).toBe(false);+ expect(document.querySelector("[data-dbx-context-menu]")).toBeNull();+ });++ it("keeps the DataGrid context menu for a regular cell", async () => {+ const { host } = mountGrid(hydratedResult(1, "value"));+ await settle();++ openContextMenu(gridCell(host));+ await settle();++ expect(contextMenuLabels()).toContain("Filter");+ });++ it("keeps the native context menu for the expanded condition editor", async () => {+ const { host } = mountGrid(hydratedResult(1, "abcdefghijklmnopqrstuvwxyz"));+ await settle();++ const input = host.querySelector<HTMLTextAreaElement>('textarea[placeholder="WHERE"]');+ expect(input).not.toBeNull();+ input!.value = "abcdefghijklmnopqrstuvwxyz";+ input!.setSelectionRange(input!.value.length, input!.value.length);+ Object.defineProperties(input!, {+ clientWidth: { configurable: true, value: 80 },+ scrollWidth: { configurable: true, value: 320 },+ clientHeight: { configurable: true, value: 24 },+ scrollHeight: { configurable: true, value: 24 },+ });++ const originalGetBoundingClientRect = HTMLElement.prototype.getBoundingClientRect;+ const rectSpy = vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(function (this: HTMLElement) {+ if (this === input) return { x: 0, y: 0, left: 0, top: 0, right: 80, bottom: 24, width: 80, height: 24, toJSON: () => ({}) } as DOMRect;+ if (this instanceof HTMLSpanElement && this.style.position === "fixed") return { x: 0, y: 0, left: 0, top: 0, right: 320, bottom: 24, width: 320, height: 24, toJSON: () => ({}) } as DOMRect;+ return originalGetBoundingClientRect.call(this);+ });++ try {+ input!.focus();+ input!.dispatchEvent(new FocusEvent("focus", { bubbles: true }));+ await settle();++ const expanded = document.body.querySelector<HTMLTextAreaElement>('.data-grid-topbar-condition-input--expanded[placeholder="WHERE"]');+ expect(expanded).not.toBeNull();++ const documentContextMenu = vi.fn((event: MouseEvent) => event.preventDefault());+ document.addEventListener("contextmenu", documentContextMenu);+ try {+ const event = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, clientX: 12, clientY: 12 });+ expanded!.dispatchEvent(event);++ expect(event.defaultPrevented).toBe(false);+ expect(documentContextMenu).not.toHaveBeenCalled();+ } finally {+ document.removeEventListener("contextmenu", documentContextMenu);+ }+ } finally {+ rectSpy.mockRestore();+ }+ });+it("preserves a newly opened header target and same-turn menu actions", async () => {const { host } = mountGrid(hydratedResult(1, "value"));await settle();