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): keep header and row numbers unhighlighted on select-all (#12853)
HARRISON425f90c6396e
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vueindex 94b929e11e..3325022b94 100644--- a/apps/desktop/src/components/grid/DataGrid.vue+++ b/apps/desktop/src/components/grid/DataGrid.vue@@ -6675,6 +6675,7 @@ function selectionFrameKindForCell(rowIndex: number, visibleColIdx: number): "si// 行号的选区覆盖指示(Navicat 风格),但行选中(--selected)和行状态色(新增/编辑/删除)优先,// 与 canvas 渲染器的 rowNumberFill 优先级顺序保持一致function rowNumberShowsSelectionTint(item: RowItem): boolean {+ if (isSelectingAll.value) return false;if (isRowSelected(item.id)) return false;if (item.status !== "clean") return false;const frames = selectionFramesData.value.frames;@@ -8789,6 +8790,7 @@ function drawCanvasGrid() {rowCellsUseSelectionVisual,cellIsSelected,selectionFrames: selectionFramesData.value.frames,+ selectingAll: isSelectingAll.value,cellCanHover: canEditCellItem,infiniteScrollEnabled: infiniteScrollEnabled.value,pageOffset: rowNumberPageOffset(),@@ -15194,9 +15196,6 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val<div class="data-grid-header-row flex w-(--header-total-w) font-semibold text-foreground"><divclass="data-grid-header-cell shrink-0 px-2 py-1.5 border-r w-(--row-num-w) border-border text-center text-muted-foreground select-none cursor-default hover:bg-gray-200 dark:hover:bg-gray-800 sticky left-0 z-20"- :class="{- 'data-grid-header-cell--selected': isSelectingAll,- }"@click="selectAllCells"@contextmenu="invalidateContextMenuTarget">diff --git a/apps/desktop/src/composables/__tests__/useDataGridSelection.spec.ts b/apps/desktop/src/composables/__tests__/useDataGridSelection.spec.tsindex f8e15ff77a..58bab4d300 100644--- a/apps/desktop/src/composables/__tests__/useDataGridSelection.spec.ts+++ b/apps/desktop/src/composables/__tests__/useDataGridSelection.spec.ts@@ -145,6 +145,17 @@ describe("useDataGridSelection", () => {expect(selection.columnIsExclusivelySelected(2)).toBe(false);});+ it("keeps headers unhighlighted after select-all because copying excludes them", () => {+ const selection = createSelection();++ selection.selectAllCells();++ expect(selection.isSelectingAll.value).toBe(true);+ expect(selection.cellIsSelected(0, 0)).toBe(true);+ expect(selection.columnIsSelected(0)).toBe(false);+ expect(selection.columnIsSelected(2)).toBe(false);+ });+it("treats an explicit multi-column header selection as exclusive for every column it contains", () => {const selection = createSelection();diff --git a/apps/desktop/src/composables/useDataGridSelection.ts b/apps/desktop/src/composables/useDataGridSelection.tsindex a2f60ebe6b..6a5f9d9767 100644--- a/apps/desktop/src/composables/useDataGridSelection.ts+++ b/apps/desktop/src/composables/useDataGridSelection.ts@@ -691,6 +691,8 @@ export function useDataGridSelection(options: UseDataGridSelectionOptions) {function columnIsSelected(colIndex: number): boolean {if (hasColumnSelection.value) return selectedColumnIndexes.value.has(colIndex);+ // Ctrl/Cmd+A 是"选中数据区":复制只包含单元格,不含表头与行号,所以表头不跟着高亮。+ if (isSelectingAll.value) return false;const range = selectedRange.value;if (!range) return false;return range.startCol <= colIndex && range.endCol >= colIndex && range.startRow === 0 && range.endRow >= displayItems.value.length - 1;diff --git a/apps/desktop/src/lib/__tests__/dataGrid/canvasDataGridRendererFrozen.spec.ts b/apps/desktop/src/lib/__tests__/dataGrid/canvasDataGridRendererFrozen.spec.tsindex 656750332c..5d76b57188 100644--- a/apps/desktop/src/lib/__tests__/dataGrid/canvasDataGridRendererFrozen.spec.ts+++ b/apps/desktop/src/lib/__tests__/dataGrid/canvasDataGridRendererFrozen.spec.ts@@ -308,6 +308,43 @@ describe("drawCanvasDataGrid with frozen columns", () => {expect(() => drawCanvasDataGrid(options)).not.toThrow();});+ it("keeps the row-number gutter unhighlighted when select-all owns the selection", () => {+ const fills: { fillStyle: string; x: number; width: number }[] = [];+ let fillStyle = "";+ const context = new Proxy(+ {},+ {+ get: (_target, key) => {+ if (key === "fillRect") return (x: number, _y: number, width: number) => fills.push({ fillStyle, x, width });+ if (key === "measureText") return () => ({ width: 0 });+ return () => {};+ },+ set: (_target, key, value) => {+ if (key === "fillStyle") fillStyle = String(value);+ return true;+ },+ },+ ) as unknown as CanvasRenderingContext2D;++ const rowNumberFills = (selectingAll: boolean) => {+ fills.length = 0;+ const canvas = createMockCanvas();+ vi.spyOn(canvas, "getContext").mockReturnValue(context);+ drawCanvasDataGrid(+ createBaseOptions({+ canvas,+ selectingAll,+ selectionFrames: [{ startRow: 0, endRow: 2, startCol: 0, endCol: 2 }],+ }),+ );+ return fills.filter((fill) => fill.x === 0 && fill.width === 40).map((fill) => fill.fillStyle);+ };++ // theme.cellSelected is the row-number "covered by selection" tint; select-all must not use it.+ expect(rowNumberFills(false)).toContain("rgb(179, 208, 254)");+ expect(rowNumberFills(true)).not.toContain("rgb(179, 208, 254)");+ });+it("draws with custom crosshair row and column colors", () => {const canvas = createMockCanvas();const optionsWithCustomCrosshairColors = createBaseOptions({diff --git a/apps/desktop/src/lib/dataGrid/canvasDataGridRenderer.ts b/apps/desktop/src/lib/dataGrid/canvasDataGridRenderer.tsindex 3c0e4290fa..f02f6871e0 100644--- a/apps/desktop/src/lib/dataGrid/canvasDataGridRenderer.ts+++ b/apps/desktop/src/lib/dataGrid/canvasDataGridRenderer.ts@@ -92,6 +92,8 @@ export interface DrawCanvasDataGridOptions {/** 连续选区矩形(displayRow/visibleCol 坐标)。用于 Navicat 风格的形态区分:* 多格范围浅色填充 + 一圈细外框、内部零描边;1×1 画细边框;离散点选传空数组退回逐格描边 */selectionFrames?: readonly CellSelectionRange[];+ /** Ctrl/Cmd+A 整表选中:只高亮数据格,行号栏不做选区覆盖着色(复制不含行号) */+ selectingAll?: boolean;cellCanHover: (row: CanvasDataGridRow, actualColIdx: number) => boolean;infiniteScrollEnabled: boolean;pageOffset: number;@@ -388,6 +390,7 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions): booleanrowCellsUseSelectionVisual,cellIsSelected,selectionFrames = [],+ selectingAll = false,cellCanHover,infiniteScrollEnabled,pageOffset,@@ -499,7 +502,7 @@ export function drawCanvasDataGrid(options: DrawCanvasDataGridOptions): boolean// 选区覆盖指示(Navicat 风格):行落在选区范围内时行号淡色高亮;// 优先级低于行选中/状态色/活动行,与 DOM 的级联顺序一致- const rowInSelection = !rowSelectionVisual && selectionRowCoverage && dataGridFrameCoversRow(selectionFrames, item.displayIndex);+ const rowInSelection = !selectingAll && !rowSelectionVisual && selectionRowCoverage && dataGridFrameCoversRow(selectionFrames, item.displayIndex);const rowNumberFill = rowSelectionVisual? theme.rowNumberSelected: item.status === "draft"