Skip to content

Commit

Permalink
fix #1246, for case 3
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed May 8, 2017
1 parent b6321fa commit 7104c6b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/TableEditColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TableEditColumn extends Component {
super(props);
this.timeouteClear = 0;
const { fieldValue, row, className } = this.props;
this.focusInEditor = this.focusInEditor.bind(this);
this.state = {
shakeEditor: false,
className: typeof className === 'function' ? className(fieldValue, row) : className
Expand Down Expand Up @@ -74,7 +75,6 @@ class TableEditColumn extends Component {
const ts = this;
let valid = true;
if (ts.props.editable.validator) {
const input = ts.refs.inputRef;
const checkVal = ts.props.editable.validator(value, this.props.row);
const responseType = typeof checkVal;
if (responseType !== 'object' && checkVal !== true) {
Expand All @@ -97,7 +97,7 @@ class TableEditColumn extends Component {
ts.timeouteClear = setTimeout(() => {
ts.setState({ shakeEditor: false });
}, 300);
input.focus();
this.focusInEditor();
return valid;
}
}
Expand All @@ -124,7 +124,7 @@ class TableEditColumn extends Component {
}

componentDidMount() {
this.refs.inputRef.focus();
this.focusInEditor();
const dom = ReactDOM.findDOMNode(this);
if (this.props.isFocus) {
dom.focus();
Expand All @@ -146,6 +146,12 @@ class TableEditColumn extends Component {
this.clearTimeout();
}

focusInEditor() {
if (typeof this.refs.inputRef.focus === 'function') {
this.refs.inputRef.focus();
}
}

handleClick = e => {
if (e.target.tagName !== 'TD') {
e.stopPropagation();
Expand Down

0 comments on commit 7104c6b

Please sign in to comment.