Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/components/Search/SearchPageHeaderInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function SearchPageHeaderInput({queryJSON, children}: SearchPageHeaderInputProps
const updatedSubstitutionsMap = getUpdatedSubstitutionsMap(userQuery, autocompleteSubstitutions);
setAutocompleteSubstitutions(updatedSubstitutionsMap);

if (updatedUserQuery || textInputValue.length > 0) {
if (updatedUserQuery) {
listRef.current?.updateAndScrollToFocusedIndex(0);
} else {
listRef.current?.updateAndScrollToFocusedIndex(-1);
Expand All @@ -148,9 +148,12 @@ function SearchPageHeaderInput({queryJSON, children}: SearchPageHeaderInputProps
setTextInputValue('');
setAutocompleteQueryValue('');
setIsAutocompleteListVisible(false);
} else {
setTextInputValue(queryText);
setAutocompleteQueryValue(queryText);
}
},
[autocompleteSubstitutions, originalInputQuery, queryJSON.policyID],
[autocompleteSubstitutions, originalInputQuery, queryJSON.policyID, queryText],
);

const onListItemPress = useCallback(
Expand Down Expand Up @@ -260,6 +263,10 @@ function SearchPageHeaderInput({queryJSON, children}: SearchPageHeaderInputProps
onSearchQueryChange={onSearchQueryChange}
isFullWidth
onSubmit={() => {
const focusedOption = listRef.current?.getFocusedOption();
if (focusedOption) {
return;
}
submitSearch(textInputValue);
}}
autoFocus={false}
Expand Down