Skip to content

Commit

Permalink
fix(filterQuery): reset query on icon click
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamNowotny committed Aug 28, 2024
1 parent ec7ff01 commit 46699c4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/filterQuery/filterQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import { Form } from 'react-bootstrap';

export default ({ onUpdate }: { onUpdate: (string) => void }) => {
const [query, setQuery] = useState('');

const updateQuery = value => {
setQuery(value);
onUpdate(value);
};

const handleKeyDown = e => {
if (e.key === 'Escape') {
e.preventDefault();
setQuery('');
onUpdate('');
updateQuery('');
}
};
const handleChange = e => {
const value = e.target.value;
setQuery(value);
onUpdate(value);
updateQuery(value);
};

return (
Expand All @@ -31,7 +35,7 @@ export default ({ onUpdate }: { onUpdate: (string) => void }) => {
<i
className="reset-icon fa fa-times-circle-o fa-2x"
onClick={() => {
setQuery('');
updateQuery('');
}}
></i>
)}
Expand Down

0 comments on commit 46699c4

Please sign in to comment.