fix: should support child.ref in AutoComplete, close: #6814 (#7237)

pull/7238/head
Benjy Cui 8 years ago committed by 偏右
parent f9273bc95a
commit 26d746bd8f

@ -10,10 +10,17 @@ export default class InputElement extends React.Component<any, any> {
blur = () => {
this.ele.blur ? this.ele.blur() : (findDOMNode(this.ele) as HTMLInputElement).blur();
}
saveRef = (ele: HTMLInputElement) => {
this.ele = ele;
const childRef = this.props.children.ref;
if (typeof childRef === 'function') {
childRef(ele);
}
}
render() {
return React.cloneElement(this.props.children, {
...this.props,
ref: ele => this.ele = (ele as HTMLInputElement),
ref: this.saveRef,
}, null);
}
}

Loading…
Cancel
Save