fix(grid): sync value editor with selected cell
This commit is contained in:
@@ -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"/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user