Skip to content

Commit

Permalink
fix #1750
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Nov 20, 2017
1 parent db634db commit b52e065
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class TableBody extends Component {

handleCellKeyDown = (e, lastEditCell) => {
e.preventDefault();
const { keyBoardNav, onNavigateCell, cellEdit } = this.props;
const { keyBoardNav, onNavigateCell, cellEdit, selectedRowKeys } = this.props;
let offset;
if (e.keyCode === 37) {
offset = { x: -1, y: 0 };
Expand All @@ -268,21 +268,30 @@ class TableBody extends Component {
} else if (e.keyCode === 40) {
offset = { x: 0, y: 1 };
} else if (e.keyCode === 13) {
const rowIndex = e.target.parentElement.rowIndex + 1;
const enterToEdit = typeof keyBoardNav === 'object' ?
keyBoardNav.enterToEdit :
false;
const enterToExpand = typeof keyBoardNav === 'object' ?
keyBoardNav.enterToExpand :
false;
const enterToSelect = typeof keyBoardNav === 'object' ?
keyBoardNav.enterToSelect :
false;

if (cellEdit && enterToEdit) {
this.handleEditCell(e.target.parentElement.rowIndex + 1,
e.currentTarget.cellIndex, '', e);
this.handleEditCell(rowIndex, e.currentTarget.cellIndex, '', e);
}

if (enterToExpand) {
this.handleClickCell(this.props.y + 1, this.props.x);
}

if (enterToSelect) {
const isSelected = selectedRowKeys.indexOf(
this.props.data[rowIndex - 1][this.props.keyField]) !== -1;
this.handleSelectRow(rowIndex, !isSelected, e);
}
}
if (offset && keyBoardNav) {
onNavigateCell(offset);
Expand Down

0 comments on commit b52e065

Please sign in to comment.