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): preselect first WHERE field completion suggestion
二丫讲梵2c7a420ef611
diff --git a/apps/desktop/src/components/grid/__tests__/DataGridConditionEditor.spec.ts b/apps/desktop/src/components/grid/__tests__/DataGridConditionEditor.spec.tsindex b2a65cd11e..c3890cfb2a 100644--- a/apps/desktop/src/components/grid/__tests__/DataGridConditionEditor.spec.ts+++ b/apps/desktop/src/components/grid/__tests__/DataGridConditionEditor.spec.ts@@ -195,6 +195,21 @@ describe("DataGridConditionEditor quote completion", () => {expect(value.value).toBe("name");});+ it("selects the first WHERE field suggestion with Enter", async () => {+ const { value, input } = mountEditor("where", "", { columns: ["customer_id", "customer_name"] });+ input.focus();+ input.value = "cus";+ input.setSelectionRange(3, 3);+ input.dispatchEvent(new Event("input", { bubbles: true }));++ await vi.waitFor(() => expect(document.querySelectorAll('[role="option"]')).toHaveLength(2));+ expect(document.querySelector('[role="option"][aria-selected="true"]')?.textContent).toContain("customer_id");++ input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }));+ await nextTick();+ expect(value.value).toBe("customer_id");+ });+it("does not select a suggestion just because the dropdown appears under the mouse", async () => {const { value, input } = mountEditor("orderBy", "", { columns: ["name", "namespace"] });input.focus();diff --git a/apps/desktop/src/composables/__tests__/useDataGridConditionEditor.spec.ts b/apps/desktop/src/composables/__tests__/useDataGridConditionEditor.spec.tsindex ece02c489c..bfa92cdada 100644--- a/apps/desktop/src/composables/__tests__/useDataGridConditionEditor.spec.ts+++ b/apps/desktop/src/composables/__tests__/useDataGridConditionEditor.spec.ts@@ -33,7 +33,6 @@ describe("useDataGridConditionEditor", () => {value.value = "status = cust";await nextTick();await vi.waitFor(() => expect(editor.suggestions.value.map((item) => item.value)).toEqual(["customer_id", "customer_name"]));- expect(editor.navigate(1)).toBe(true);expect(editor.highlightedIndex.value).toBe(0);expect(editor.navigate(1)).toBe(true);expect(editor.highlightedIndex.value).toBe(1);diff --git a/apps/desktop/src/composables/useDataGridConditionEditor.ts b/apps/desktop/src/composables/useDataGridConditionEditor.tsindex 57aea0741c..f34208c6f7 100644--- a/apps/desktop/src/composables/useDataGridConditionEditor.ts+++ b/apps/desktop/src/composables/useDataGridConditionEditor.ts@@ -283,7 +283,7 @@ export function useDataGridConditionEditor(options: UseDataGridConditionEditorOpconst providerValues = values ? [...new Set(values)] : undefined;suggestions.value = providerValues ? (providerValues.some((value) => value.toLowerCase() === target.token.toLowerCase()) ? [] : providerValues.slice(0, limit).map((suggestion) => ({ value: suggestion, kind: "column" }))) : defaultSuggestions(target).slice(0, limit);replacementRange.value = { from: target.from, to: target.to };- highlightedIndex.value = -1;+ highlightedIndex.value = options.kind === "where" && suggestions.value[0]?.kind === "column" ? 0 : -1;} catch (error) {if (!controller.signal.aborted && requestId === suggestionRequestId) {suggestions.value = [];