20260730173012
This commit is contained in:
1 parent
84673b3d3d
commit
4929b78434
25 files changed
+1796
-68
No files matched your search
@@ -85,6 +85,28 @@ function clearActiveEditing() {
|
||||
if (state) state.value = { editing: false, focusCol: null, initialValues: null };
|
||||
}
|
||||
|
||||
// 父级可能在 change 后回灌同 rowKey 的新对象,编辑状态需要随行对象迁移。
|
||||
function rebindActiveEditingRow(rows) {
|
||||
if (!activeEditingRow || rows.includes(activeEditingRow)) return;
|
||||
|
||||
const previousRow = activeEditingRow;
|
||||
const previousState = rowEditingStates.get(previousRow)?.value;
|
||||
const previousKey = getRowKey(previousRow);
|
||||
const replacement =
|
||||
previousKey == null ? null : rows.find((row) => String(getRowKey(row)) === String(previousKey));
|
||||
|
||||
clearActiveEditing();
|
||||
if (!replacement || !previousState?.editing) return;
|
||||
|
||||
const state = getRowEditingState(replacement);
|
||||
activeEditingRow = replacement;
|
||||
state.value = {
|
||||
editing: true,
|
||||
focusCol: previousState.focusCol,
|
||||
initialValues: captureEditableValues(replacement),
|
||||
};
|
||||
}
|
||||
|
||||
function activateEditing(row, focusCol) {
|
||||
if (!props.editable || !row) return;
|
||||
const state = getRowEditingState(row);
|
||||
@@ -402,7 +424,7 @@ function handleAreaSelectionChange(ranges) {
|
||||
watch(
|
||||
[() => props.activeRowKey, () => props.dataSource],
|
||||
async ([rowKey]) => {
|
||||
if (activeEditingRow && !props.dataSource.includes(activeEditingRow)) clearActiveEditing();
|
||||
rebindActiveEditingRow(props.dataSource);
|
||||
await nextTick();
|
||||
if (rowKey == null) {
|
||||
tableRef.value?.setCurrentRow?.(undefined, { silent: true });
|
||||
|
||||
Reference in new issue
Block a user