Skip to content

Commit

Permalink
fix #1228
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Apr 25, 2017
1 parent ec62138 commit 1a6ca0a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/TableEditColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ class TableEditColumn extends Component {
}

handleKeyPress = e => {
if (e.keyCode === 13) {
if (e.keyCode === 13 || e.keyCode === 9) {
// Pressed ENTER
const value = e.currentTarget.type === 'checkbox' ?
this._getCheckBoxValue(e) : e.currentTarget.value;

if (!this.validator(value)) {
return;
}
this.props.completeEdit(value, this.props.rowIndex, this.props.colIndex);
if (e.keyCode === 13) {
this.props.completeEdit(value, this.props.rowIndex, this.props.colIndex);
} else {
this.props.onTab(this.props.rowIndex + 1, this.props.colIndex + 1, 'tab', e);
e.preventDefault();
}
} else if (e.keyCode === 27) {
this.props.completeEdit(
null, this.props.rowIndex, this.props.colIndex);
} else if (e.keyCode === 9) {
this.props.onTab(this.props.rowIndex + 1, this.props.colIndex + 1, 'tab', e);
e.preventDefault();
} else if (e.type === 'click' && !this.props.blurToSave) { // textarea click save button
const value = e.target.parentElement.firstChild.value;
if (!this.validator(value)) {
Expand All @@ -48,7 +50,7 @@ class TableEditColumn extends Component {
const value = e.currentTarget.type === 'checkbox' ?
this._getCheckBoxValue(e) : e.currentTarget.value;
if (!this.validator(value)) {
return;
return false;
}
this.props.completeEdit(
value, this.props.rowIndex, this.props.colIndex);
Expand Down

0 comments on commit 1a6ca0a

Please sign in to comment.