Skip to content

Commit

Permalink
chore(odd-platform-api): fix comments (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolii-yemets committed Feb 20, 2024
1 parent 0876771 commit d3851b4
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,26 @@ const QueryExamplesAutocomplete: React.FC<QueryExamplesAutocompleteProps> = ({
return '';
}, []);

const handleInput = (input: string) => {
setQuery(input);
setAutocompleteOpen(!!input);
};

const handleSelection = () => {
setQuery(''); // Clear input on select
setAutocompleteOpen(false);
};

const searchInputChange = useCallback(
(
_: React.ChangeEvent<unknown>,
input: string,
reason: AutocompleteInputChangeReason
) => {
if (reason === 'input') {
setQuery(input);
if (!input) {
setAutocompleteOpen(false);
} else {
setAutocompleteOpen(true);
}
handleInput(input);
} else {
setQuery(''); // Clear input on select
setAutocompleteOpen(false);
handleSelection();
}
},
[setQuery]
Expand Down

0 comments on commit d3851b4

Please sign in to comment.