Skip to content

Commit 2f9ed93

Browse files
committed
fix #1137
1 parent e713488 commit 2f9ed93

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

src/TableBody.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,13 @@ class TableBody extends Component {
342342
if (expandColumnVisible) columnIndex++;
343343
this.handleCompleteEditCell(e.target.value, rowIndex, columnIndex - 1);
344344
if (columnIndex >= this.props.columns.length) {
345-
rowIndex = rowIndex + 1;
346-
columnIndex = 1;
347345
this.handleCellKeyDown(e, true);
348346
} else {
349347
this.handleCellKeyDown(e);
350348
}
349+
const { nextRIndex, nextCIndex } = this.nextEditableCell(rowIndex, columnIndex);
350+
rowIndex = nextRIndex;
351+
columnIndex = nextCIndex;
351352
}
352353

353354
const stateObj = {
@@ -366,6 +367,32 @@ class TableBody extends Component {
366367
this.setState(stateObj);
367368
}
368369

370+
nextEditableCell = (rIndex, cIndex) => {
371+
const { keyField } = this.props;
372+
let nextRIndex = rIndex;
373+
let nextCIndex = cIndex;
374+
let row;
375+
let column;
376+
do {
377+
if (nextCIndex >= this.props.columns.length) {
378+
nextRIndex++;
379+
nextCIndex = 0;
380+
}
381+
row = this.props.data[nextRIndex];
382+
column = this.props.columns[nextCIndex];
383+
if (!row) break;
384+
let editable = column.editable;
385+
if (isFun(column.editable)) {
386+
editable = column.editable(column, row, nextRIndex, nextCIndex);
387+
}
388+
if (editable && !column.hidden && keyField !== column.name) break;
389+
else {
390+
nextCIndex++;
391+
}
392+
} while (row);
393+
return { nextRIndex, nextCIndex };
394+
}
395+
369396
handleCompleteEditCell = (newVal, rowIndex, columnIndex) => {
370397
this.setState({ currEditCell: null });
371398
if (newVal !== null) {

0 commit comments

Comments
 (0)