mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
optimize for b7621c9
This commit is contained in:
parent
f2f786d66d
commit
c537030dee
@ -116,35 +116,6 @@ export default class Input extends Component<InputProps, any> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
|
||||||
const { props, state, refs } = this;
|
|
||||||
const preHasPresuffix = prevProps.prefix || prevProps.suffix;
|
|
||||||
const curHasPresuffix = props.prefix || props.suffix;
|
|
||||||
if (state.isFocus && (preHasPresuffix !== curHasPresuffix)) {
|
|
||||||
refs.input.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleFocus = (e) => {
|
|
||||||
const { onFocus } = this.props;
|
|
||||||
this.setState({
|
|
||||||
isFocus: true,
|
|
||||||
});
|
|
||||||
if (onFocus) {
|
|
||||||
onFocus(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleBlur = (e) => {
|
|
||||||
const { onBlur } = this.props;
|
|
||||||
this.setState({
|
|
||||||
isFocus: false,
|
|
||||||
});
|
|
||||||
if (onBlur) {
|
|
||||||
onBlur(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleKeyDown = (e) => {
|
handleKeyDown = (e) => {
|
||||||
const { onPressEnter, onKeyDown } = this.props;
|
const { onPressEnter, onKeyDown } = this.props;
|
||||||
if (e.keyCode === 13 && onPressEnter) {
|
if (e.keyCode === 13 && onPressEnter) {
|
||||||
@ -219,7 +190,7 @@ export default class Input extends Component<InputProps, any> {
|
|||||||
renderLabeledIcon(children) {
|
renderLabeledIcon(children) {
|
||||||
const { props } = this;
|
const { props } = this;
|
||||||
|
|
||||||
if (props.type === 'textarea' || (!props.prefix && !props.suffix)) {
|
if (props.type === 'textarea' || !('prefix' in props || 'suffix' in props)) {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,8 +263,6 @@ export default class Input extends Component<InputProps, any> {
|
|||||||
{...otherProps}
|
{...otherProps}
|
||||||
className={inputClassName}
|
className={inputClassName}
|
||||||
onKeyDown={this.handleKeyDown}
|
onKeyDown={this.handleKeyDown}
|
||||||
onFocus={this.handleFocus}
|
|
||||||
onBlur={this.handleBlur}
|
|
||||||
ref="input"
|
ref="input"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user