Browse Source

🐛 Focus input after clear input content

pull/15184/head
afc163 6 years ago
parent
commit
1b713c94e6
No known key found for this signature in database GPG Key ID: 5F00908D72002306
  1. 7
      components/input/Input.tsx

7
components/input/Input.tsx

@ -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>) => {

Loading…
Cancel
Save