fix(grid): sync value editor with selected cell

This commit is contained in:
t8y2
2026-05-28 18:31:57 +08:00
parent 4a93abd1b9
commit a036ea1e8d
2 changed files with 23 additions and 3 deletions
+10 -2
View File
@@ -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,
});
@@ -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"/);
});