Skip to content

Commit

Permalink
trim space to allow for autocomplete sugggestion after comma
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymczakJ committed Oct 29, 2024
1 parent 73ecc8f commit f66dfee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,20 @@ function SearchRouter({onRouterClose}: SearchRouterProps) {

const onSearchChange = useCallback(
(userQuery: string) => {
setTextInputValue(userQuery);
const autocompleteParsedQuery = parseForAutocomplete(userQuery);
let newUserQuery = userQuery;
if (autocompleteSuggestions && userQuery.endsWith(',')) {
newUserQuery = `${userQuery.slice(0, userQuery.length - 1).trim()},`;
}
setTextInputValue(newUserQuery);
const autocompleteParsedQuery = parseForAutocomplete(newUserQuery);
updateAutocomplete(autocompleteParsedQuery?.autocomplete?.value ?? '', autocompleteParsedQuery?.ranges ?? [], autocompleteParsedQuery?.autocomplete?.key);
if (userQuery) {
if (newUserQuery) {
listRef.current?.updateAndScrollToFocusedIndex(0);
} else {
listRef.current?.updateAndScrollToFocusedIndex(-1);
}
},
[setTextInputValue, updateAutocomplete],
[autocompleteSuggestions, setTextInputValue, updateAutocomplete],
);

const onSearchSubmit = useCallback(
Expand Down

0 comments on commit f66dfee

Please sign in to comment.