Ensure single character changes to non-focused fields are properly persisted when changing focused row
This commit is contained in:
parent
e1ee233aaf
commit
38c405ff6f
|
@ -564,7 +564,6 @@ export const initialise = context => {
|
||||||
previousFocusedCellId,
|
previousFocusedCellId,
|
||||||
rows,
|
rows,
|
||||||
validation,
|
validation,
|
||||||
focusedCellId,
|
|
||||||
} = context
|
} = context
|
||||||
|
|
||||||
// Wipe the row change cache when changing row
|
// Wipe the row change cache when changing row
|
||||||
|
@ -582,20 +581,12 @@ export const initialise = context => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Stop if we changed row
|
const { id: rowId, field } = parseCellID(id)
|
||||||
const split = parseCellID(id)
|
const hasChanges = field in (get(rowChangeCache)[rowId] || {})
|
||||||
const oldRowId = split.id
|
const hasErrors = validation.actions.rowHasErrors(rowId)
|
||||||
const oldColumn = split.field
|
const isSavingChanges = get(inProgressChanges)[rowId]
|
||||||
const { id: newRowId } = parseCellID(get(focusedCellId))
|
if (rowId && !hasErrors && hasChanges && !isSavingChanges) {
|
||||||
if (oldRowId !== newRowId) {
|
await rows.actions.applyRowChanges(rowId)
|
||||||
return
|
|
||||||
}
|
|
||||||
// Otherwise we just changed cell in the same row
|
|
||||||
const hasChanges = oldColumn in (get(rowChangeCache)[oldRowId] || {})
|
|
||||||
const hasErrors = validation.actions.rowHasErrors(oldRowId)
|
|
||||||
const isSavingChanges = get(inProgressChanges)[oldRowId]
|
|
||||||
if (oldRowId && !hasErrors && hasChanges && !isSavingChanges) {
|
|
||||||
await rows.actions.applyRowChanges(oldRowId)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue