Clear search (#14655)

This commit is contained in:
Geido 2021-05-17 23:30:16 +03:00 committed by GitHub
parent eb9dafc872
commit ea96d95622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -42,6 +42,12 @@ export default function SearchFilter({
setValue('');
onSubmit('');
};
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setValue(e.currentTarget.value);
if (e.currentTarget.value === '') {
onClear();
}
};
return (
<FilterContainer>
@ -50,9 +56,7 @@ export default function SearchFilter({
placeholder={Header}
name={name}
value={value}
onChange={e => {
setValue(e.currentTarget.value);
}}
onChange={handleChange}
onSubmit={handleSubmit}
onClear={onClear}
/>