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): preserve row selection during infinite-scroll append
zipg509a1530f658
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vueindex 65cb11f128..b8b9fc2487 100644--- a/apps/desktop/src/components/grid/DataGrid.vue+++ b/apps/desktop/src/components/grid/DataGrid.vue@@ -141,7 +141,7 @@ import { isCancelSearchShortcut, isCopyCurrentRowShortcut, isDeleteCurrentRowShoimport { dataGridHeaderContentWidth, scrollbarGutterWidth } from "@/lib/dataGrid/dataGridScrollGutter";import { canFetchNextDataGridSegment, canGoNextDataGridPage, dataGridTotalRowCountLabelKey, hasCompleteLocalDataGridResult, resolveDataGridPaginationTotal, type DataGridInexactTotalRowCountMode } from "@/lib/dataGrid/dataGridPagination";import { dataGridCountQueryOptions } from "@/lib/dataGrid/dataGridQueryOptions";-import { dataGridBottomScrollTop, dataGridScrollPosition, isDataGridAtScrollBottom, isDataGridNearScrollBottom, shouldCheckInfiniteScrollAfterScroll, type DataGridScrollPosition } from "@/lib/dataGrid/dataGridInfiniteScroll";+import { dataGridBottomScrollTop, dataGridScrollPosition, isDataGridAtScrollBottom, isDataGridNearScrollBottom, isDataGridPrefixAppend, shouldCheckInfiniteScrollAfterScroll, type DataGridScrollPosition } from "@/lib/dataGrid/dataGridInfiniteScroll";import { CANVAS_DATA_GRID_ROW_HEIGHT, canvasDataGridActionOverlayWidth, canvasDataGridActionReservedWidth, dataGridSearchMatchKey, drawCanvasDataGrid, type CanvasDevicePixelSize } from "@/lib/dataGrid/canvasDataGridRenderer";import { DATA_GRID_DARK_STRIPED_ROW_BG, DATA_GRID_LIGHT_STRIPED_ROW_BG, dataGridActiveRowBackground } from "@/lib/dataGrid/dataGridPaintTheme";import { createRowLowerTextCache } from "@/lib/dataGrid/dataGridRowLowerText";@@ -7112,9 +7112,10 @@ watch(isTransposeMode, (active) => {watch(() => props.result,- () => {+ (result, previousResult) => {const shouldPreserveTranspose = preserveTransposeOnNextResult.value;preserveTransposeOnNextResult.value = false;+ if (isDataGridPrefixAppend(previousResult, result)) return;if (getResetScrollAfterResult()) {clearResetScrollAfterResult();resetGridVerticalScroll();diff --git a/apps/desktop/src/lib/dataGrid/dataGridInfiniteScroll.ts b/apps/desktop/src/lib/dataGrid/dataGridInfiniteScroll.tsindex 73cb95c26c..cb3170934c 100644--- a/apps/desktop/src/lib/dataGrid/dataGridInfiniteScroll.ts+++ b/apps/desktop/src/lib/dataGrid/dataGridInfiniteScroll.ts@@ -9,6 +9,11 @@ export interface DataGridScrollMetrics {clientHeight: number;}+export interface DataGridAppendResult {+ rows: readonly unknown[];+ appended_from_row_count?: number;+}+export function dataGridScrollPosition(top: number, left: number): DataGridScrollPosition {return {top: Math.max(0, top),@@ -30,6 +35,11 @@ export function isDataGridNearScrollBottom(metrics: DataGridScrollMetrics, thresreturn metrics.scrollHeight - metrics.scrollTop - metrics.clientHeight < threshold;}+export function isDataGridPrefixAppend(previous: DataGridAppendResult | undefined, next: DataGridAppendResult): boolean {+ if (!previous || next.appended_from_row_count !== previous.rows.length || next.rows.length < previous.rows.length) return false;+ return previous.rows.every((row, index) => row === next.rows[index]);+}+export function isDataGridAtScrollBottom(metrics: DataGridScrollMetrics, tolerance = 1): boolean {const maxScrollTop = Math.max(0, metrics.scrollHeight - metrics.clientHeight);return maxScrollTop - metrics.scrollTop <= tolerance;diff --git a/packages/app-tests/dataGridInfiniteScroll.test.ts b/packages/app-tests/dataGridInfiniteScroll.test.tsindex 277e031f2a..582df59de3 100644--- a/packages/app-tests/dataGridInfiniteScroll.test.ts+++ b/packages/app-tests/dataGridInfiniteScroll.test.ts@@ -1,7 +1,7 @@import { strict as assert } from "node:assert";import { readFileSync } from "node:fs";import { test } from "vitest";-import { dataGridScrollPosition, isDataGridNearScrollBottom, shouldCheckInfiniteScrollAfterScroll } from "../../apps/desktop/src/lib/dataGrid/dataGridInfiniteScroll.ts";+import { dataGridScrollPosition, isDataGridNearScrollBottom, isDataGridPrefixAppend, shouldCheckInfiniteScrollAfterScroll } from "../../apps/desktop/src/lib/dataGrid/dataGridInfiniteScroll.ts";test("horizontal-only scroll does not check infinite scroll", () => {assert.equal(shouldCheckInfiniteScrollAfterScroll(dataGridScrollPosition(240, 0), dataGridScrollPosition(240, 180)), false);@@ -25,6 +25,21 @@ test("near-bottom check matches the grid threshold", () => {assert.equal(isDataGridNearScrollBottom({ scrollTop: 800, scrollHeight: 1000, clientHeight: 100 }), false);});+test("prefix-only append preserves the existing result identity", () => {+ const first = [1, "Ada"];+ const second = [2, "Linus"];+ const previous = { rows: [first, second] };+ assert.equal(isDataGridPrefixAppend(previous, { rows: [first, second, [3, "Grace"]], appended_from_row_count: 2 }), true);+});++test("append marker does not preserve state when an existing row was replaced", () => {+ const first = [1, "Ada"];+ const second = [2, "Linus"];+ const previous = { rows: [first, second] };+ assert.equal(isDataGridPrefixAppend(previous, { rows: [first, [...second], [3, "Grace"]], appended_from_row_count: 2 }), false);+ assert.equal(isDataGridPrefixAppend(previous, { rows: [first, second, [3, "Grace"]] }), false);+});+test("infinite scroll requests only the next bounded segment", () => {const source = readFileSync("apps/desktop/src/components/grid/DataGrid.vue", "utf8");assert.match(source, /function infiniteScrollNextPage\(\) \{[\s\S]*?if \(!canFetchNextInfiniteScrollSegment\.value\) \{[\s\S]*?infiniteScrollAllLoaded = true;[\s\S]*?return;[\s\S]*?\}/);