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): sync value editor with selected cell

t8y2a036ea1e8d33
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index c430fac038..4f4bc9cf0a 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -2195,8 +2195,16 @@ async function prefetchDetailSqlCondition() {
}
}
-watch(activeCellDetail, () => {
+watch(activeCellDetail, (detail) => {
void prefetchDetailSqlCondition();
+ if (activeCellDetailTab.value !== "valueEditor") return;
+ if (!detail?.isEditable) {
+ resetDetailEdit();
+ return;
+ }
+ detailEditValue.value = cellDetailEditorText(detail.value, detail.type);
+ syncEditorFromDetailEdit();
+ isEditingDetail.value = true;
});
const detailEditValue = ref("");
@@ -2658,7 +2666,7 @@ watch([selectedRange, showCellDetail, isEditingDetail], () => {
const selectedCell = currentSelectedCellPosition();
const target = linkedCellDetailTarget({
isOpen: showCellDetail.value,
- isEditing: isEditingDetail.value,
+ isEditing: isEditingDetail.value && activeCellDetailTab.value !== "valueEditor",
selectedCell: selectedCell ? { rowIndex: selectedCell.rowIndex, visibleColIndex: selectedCell.colIndex } : null,
actualColumnIndex,
});
diff --git a/packages/app-tests/cellDetailPresentation.test.ts b/packages/app-tests/cellDetailPresentation.test.ts
index 2d04d11b21..7e1b970618 100644
--- a/packages/app-tests/cellDetailPresentation.test.ts
+++ b/packages/app-tests/cellDetailPresentation.test.ts
@@ -86,6 +86,18 @@ test("cell detail action focuses the hovered cell before opening details", () =>
/function showCellDetailsForVisibleCell\(rowIndex: number, visibleColIdx: number, actualColIdx: number\)/,
);
assert.match(source, /selectSingleCell\(rowIndex, visibleColIdx\)/);
- assert.match(source, /@click\.stop="showCellDetailsForVisibleCell\(item\.displayIndex, visibleColIdx, actualColIdx\)"/);
+ assert.match(
+ source,
+ /@click\.stop="showCellDetailsForVisibleCell\(item\.displayIndex, visibleColIdx, actualColIdx\)"/,
+ );
assert.doesNotMatch(source, /@click\.stop="showCellDetails\(item\.displayIndex, actualColIdx\)"/);
});
+
+test("cell detail value editor follows selection and refreshes the editor content", () => {
+ const source = readFileSync("apps/desktop/src/components/grid/DataGrid.vue", "utf8");
+
+ assert.match(source, /if \(activeCellDetailTab\.value !== "valueEditor"\) return;/);
+ assert.match(source, /detailEditValue\.value = cellDetailEditorText\(detail\.value, detail\.type\)/);
+ assert.match(source, /syncEditorFromDetailEdit\(\)/);
+ assert.match(source, /isEditing: isEditingDetail\.value && activeCellDetailTab\.value !== "valueEditor"/);
+});