Skip to content

Commit

Permalink
Merge pull request #55636 from ishakakkad/55433-search-filter-clear-fix
Browse files Browse the repository at this point in the history
Removing one value from Search filter clears the search
  • Loading branch information
luacmartins authored Jan 23, 2025
2 parents 2550438 + 82c5532 commit 136b291
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit 136b291

Please sign in to comment.