diff --git a/src/core/data_proxy.js b/src/core/data_proxy.js index c931b1d3..abb542f9 100644 --- a/src/core/data_proxy.js +++ b/src/core/data_proxy.js @@ -347,6 +347,8 @@ export default class DataProxy { this.exceptRowSet = new Set(); this.sortedRowMap = new Map(); this.unsortedRowMap = new Map(); + this.currentEditRowIdx = null; + this.currentEditColIdx = null; } addValidation(mode, ref, validator) { @@ -964,14 +966,30 @@ export default class DataProxy { return this.getCellStyleOrDefault(ri, ci); } + isStartEditing(rowIdx, colIdx) { + if (this.currentEditRowIdx === null && this.currentEditColIdx === null) { + this.currentEditRowIdx = rowIdx; + this.currentEditColIdx = colIdx; + return true; + } + return false; + } + + stopEditing() { + this.currentEditRowIdx = null; + this.currentEditColIdx = null; + } + // state: input | finished setCellText(ri, ci, text, state) { const { rows, history, validations } = this; if (state === 'finished') { - rows.setCellText(ri, ci, ''); - history.add(this.getData()); rows.setCellText(ri, ci, text); + this.stopEditing(); } else { + if (this.isStartEditing(ri, ci)) { + history.add(this.getData()); + } rows.setCellText(ri, ci, text); this.change(this.getData()); }