Skip to content

Commit 58de9d6

Browse files
committed
support enterToEdit for cellediting and keyboard navigation
1 parent ff60628 commit 58de9d6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/TableBody.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class TableBody extends Component {
197197

198198
handleCellKeyDown = (e, lastEditCell) => {
199199
e.preventDefault();
200+
const { keyBoardNav, onNavigateCell, cellEdit } = this.props;
200201
let offset;
201202
if (e.keyCode === 37) {
202203
offset = { x: -1, y: 0 };
@@ -212,9 +213,17 @@ class TableBody extends Component {
212213
}
213214
} else if (e.keyCode === 40) {
214215
offset = { x: 0, y: 1 };
216+
} else if (e.keyCode === 13) {
217+
const enterToEdit = typeof keyBoardNav === 'object' ?
218+
keyBoardNav.enterToEdit :
219+
false;
220+
if (cellEdit && enterToEdit) {
221+
this.handleEditCell(e.target.parentElement.rowIndex + 1,
222+
e.currentTarget.cellIndex, '', e);
223+
}
215224
}
216-
if (offset && this.props.keyBoardNav) {
217-
this.props.onNavigateCell(offset);
225+
if (offset && keyBoardNav) {
226+
onNavigateCell(offset);
218227
}
219228
}
220229

0 commit comments

Comments
 (0)