Add focus and blur support to InputNumber (#7615)

* Add focus support to InputNumber

* Convert string ref to private ref

* Added blur method and fixed linting
pull/7572/merge
delesseps 7 years ago committed by niko
parent ea5ccce90d
commit 174c98cdca

@ -28,6 +28,8 @@ export default class InputNumber extends React.Component<InputNumberProps, any>
step: 1, step: 1,
}; };
private inputNumberRef: any;
render() { render() {
const { className, size, ...others } = this.props; const { className, size, ...others } = this.props;
const inputNumberClass = classNames({ const inputNumberClass = classNames({
@ -35,6 +37,14 @@ export default class InputNumber extends React.Component<InputNumberProps, any>
[`${this.props.prefixCls}-sm`]: size === 'small', [`${this.props.prefixCls}-sm`]: size === 'small',
}, className); }, className);
return <RcInputNumber className={inputNumberClass} {...others} />; return <RcInputNumber ref={c => this.inputNumberRef = c} className={inputNumberClass} {...others} />;
}
focus() {
this.inputNumberRef.focus();
}
blur() {
this.inputNumberRef.blur();
} }
} }

Loading…
Cancel
Save