Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix(grid): focus cell before detail

t8y2c2a13f305762
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index 7c2abec5e2..583c3ab7d3 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -2234,6 +2234,12 @@ function showCellDetails(rowIndex: number, colIndex: number) {
showCellDetail.value = true;
}
+function showCellDetailsForVisibleCell(rowIndex: number, visibleColIdx: number, actualColIdx: number) {
+ clearRowSelection();
+ selectSingleCell(rowIndex, visibleColIdx);
+ showCellDetails(rowIndex, actualColIdx);
+}
+
watch([selectedRange, showCellDetail, isEditingDetail], () => {
const selectedCell = currentSelectedCellPosition();
const target = linkedCellDetailTarget({
@@ -4105,7 +4111,7 @@ defineExpose({
class="absolute right-0.5 top-0.5 flex h-5 w-5 items-center justify-center rounded bg-background/90 text-muted-foreground shadow-sm ring-1 ring-border hover:text-foreground"
:title="t('grid.cellDetails')"
@mousedown.stop
- @click.stop="showCellDetails(index, actualColIdx)"
+ @click.stop="showCellDetailsForVisibleCell(index, visibleColIdx, actualColIdx)"
>
<Info class="h-3 w-3" />
</button>
diff --git a/packages/app-tests/cellDetailPresentation.test.ts b/packages/app-tests/cellDetailPresentation.test.ts
index afd863158e..742ac46c2a 100644
--- a/packages/app-tests/cellDetailPresentation.test.ts
+++ b/packages/app-tests/cellDetailPresentation.test.ts
@@ -1,3 +1,4 @@
+import { readFileSync } from "node:fs";
import { strict as assert } from "node:assert";
import test from "node:test";
import {
@@ -76,3 +77,15 @@ test("cell detail does not follow selection while closed or editing", () => {
assert.equal(linkedCellDetailTarget({ isOpen: true, isEditing: true, selectedCell, actualColumnIndex }), null);
assert.equal(linkedCellDetailTarget({ isOpen: true, isEditing: false, selectedCell: null, actualColumnIndex }), null);
});
+
+test("cell detail action focuses the hovered cell before opening details", () => {
+ const source = readFileSync("apps/desktop/src/components/grid/DataGrid.vue", "utf8");
+
+ assert.match(
+ source,
+ /function showCellDetailsForVisibleCell\(rowIndex: number, visibleColIdx: number, actualColIdx: number\)/,
+ );
+ assert.match(source, /selectSingleCell\(rowIndex, visibleColIdx\)/);
+ assert.match(source, /@click\.stop="showCellDetailsForVisibleCell\(index, visibleColIdx, actualColIdx\)"/);
+ assert.doesNotMatch(source, /@click\.stop="showCellDetails\(index, actualColIdx\)"/);
+});