Skip to content

Commit 7104c6b

Browse files
committed
fix #1246, for case 3
1 parent b6321fa commit 7104c6b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/TableEditColumn.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class TableEditColumn extends Component {
1010
super(props);
1111
this.timeouteClear = 0;
1212
const { fieldValue, row, className } = this.props;
13+
this.focusInEditor = this.focusInEditor.bind(this);
1314
this.state = {
1415
shakeEditor: false,
1516
className: typeof className === 'function' ? className(fieldValue, row) : className
@@ -74,7 +75,6 @@ class TableEditColumn extends Component {
7475
const ts = this;
7576
let valid = true;
7677
if (ts.props.editable.validator) {
77-
const input = ts.refs.inputRef;
7878
const checkVal = ts.props.editable.validator(value, this.props.row);
7979
const responseType = typeof checkVal;
8080
if (responseType !== 'object' && checkVal !== true) {
@@ -97,7 +97,7 @@ class TableEditColumn extends Component {
9797
ts.timeouteClear = setTimeout(() => {
9898
ts.setState({ shakeEditor: false });
9999
}, 300);
100-
input.focus();
100+
this.focusInEditor();
101101
return valid;
102102
}
103103
}
@@ -124,7 +124,7 @@ class TableEditColumn extends Component {
124124
}
125125

126126
componentDidMount() {
127-
this.refs.inputRef.focus();
127+
this.focusInEditor();
128128
const dom = ReactDOM.findDOMNode(this);
129129
if (this.props.isFocus) {
130130
dom.focus();
@@ -146,6 +146,12 @@ class TableEditColumn extends Component {
146146
this.clearTimeout();
147147
}
148148

149+
focusInEditor() {
150+
if (typeof this.refs.inputRef.focus === 'function') {
151+
this.refs.inputRef.focus();
152+
}
153+
}
154+
149155
handleClick = e => {
150156
if (e.target.tagName !== 'TD') {
151157
e.stopPropagation();

0 commit comments

Comments
 (0)