🐛 Focus input after clear input content

This commit is contained in:
afc163 2019-03-04 22:19:40 +08:00
parent 5cd5d1ff00
commit 1b713c94e6
No known key found for this signature in database
GPG Key ID: 5F00908D72002306

View File

@ -142,9 +142,10 @@ class Input extends React.Component<InputProps, any> {
setValue(
value: string,
e: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLElement, MouseEvent>,
callback?: () => void,
) {
if (!('value' in this.props)) {
this.setState({ value });
this.setState({ value }, callback);
}
const { onChange } = this.props;
if (onChange) {
@ -167,7 +168,9 @@ class Input extends React.Component<InputProps, any> {
}
handleReset = (e: React.MouseEvent<HTMLElement, MouseEvent>) => {
this.setValue('', e);
this.setValue('', e, () => {
this.focus();
});
};
handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {