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): reset infinite scroll state on database sort
t8y2246dfad018b1
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vueindex c89c980ec9..61c1042da1 100644--- a/apps/desktop/src/components/grid/DataGrid.vue+++ b/apps/desktop/src/components/grid/DataGrid.vue@@ -4379,8 +4379,12 @@ function setDetailNull() {function applyColumnSort(column: string, columnIndex: number, direction: "asc" | "desc" | null, mode: DataGridSortMode = "database") {if (getIsResizing()) return;- currentPage.value = 1;- resetGridVerticalScroll(true);+ if (mode === "database" && infiniteScrollEnabled.value) {+ resetInfiniteScrollState();+ } else {+ currentPage.value = 1;+ resetGridVerticalScroll(true);+ }if (direction) {setSort(column, columnIndex, direction, mode);if (mode === "database") {diff --git a/apps/desktop/src/components/grid/__tests__/DataGridInfiniteScrollSort.spec.ts b/apps/desktop/src/components/grid/__tests__/DataGridInfiniteScrollSort.spec.tsnew file mode 100644index 0000000000..124b5dfae8--- /dev/null+++ b/apps/desktop/src/components/grid/__tests__/DataGridInfiniteScrollSort.spec.ts@@ -0,0 +1,35 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++const dataGridSource = readFileSync(new URL("../DataGrid.vue", import.meta.url), "utf8");++function functionSource(name: string, nextName: string): string {+ const start = dataGridSource.indexOf(`function ${name}`);+ const relativeEnd = dataGridSource.slice(start).search(new RegExp(`\\n(?:async\\s+)?function\\s+${nextName}\\b`));+ expect(start).toBeGreaterThanOrEqual(0);+ expect(relativeEnd).toBeGreaterThan(0);+ const end = start + relativeEnd;+ return dataGridSource.slice(start, end);+}++describe("DataGrid infinite-scroll sorting", () => {+ it("clears completed and pending infinite-scroll state before database sorting", () => {+ const sortSource = functionSource("applyColumnSort", "selectHeaderSort");+ const resetSource = functionSource("resetInfiniteScrollState", "onToolbarRefresh");++ expect(sortSource).toContain('if (mode === "database" && infiniteScrollEnabled.value) {\n resetInfiniteScrollState();');+ expect(resetSource).toContain("lastInfiniteScrollPage = 0;");+ expect(resetSource).toContain("infiniteScrollAllLoaded = false;");+ expect(resetSource).toContain("infiniteScrollRequestedOffset = undefined;");+ expect(resetSource).toContain("infiniteScrollRequestedLimit = undefined;");+ expect(resetSource).toContain("isInfiniteScrollPaginating.value = false;");+ expect(resetSource).toContain("infiniteScrollLoading.value = false;");+ });++ it("preserves the existing lightweight reset for local sorting", () => {+ const sortSource = functionSource("applyColumnSort", "selectHeaderSort");++ expect(sortSource).toContain("} else {\n currentPage.value = 1;\n resetGridVerticalScroll(true);\n }");+ expect(sortSource.match(/emit\("sort"/g)).toHaveLength(1);+ });+});