fix: Clear search input of home page on search (#52353)

This commit is contained in:
Asif khan
2023-11-21 18:06:29 +05:30
committed by GitHub
parent a7e116af3e
commit 55dcecdb4e
2 changed files with 9 additions and 0 deletions
@@ -19,6 +19,9 @@ const SearchBarOptimized = ({
event.preventDefault();
if (value && value.length > 1) {
window.open(`${searchUrl}?query=${encodeURIComponent(value)}`, '_blank');
setValue('');
// Blur the input to remove the selection
inputElementRef.current?.blur();
}
};
const onClick = () => {
@@ -130,6 +130,12 @@ export class SearchBar extends Component<SearchBarProps, SearchBarState> {
}
updateSearchQuery(query);
//clear input value
const searchInput = e.currentTarget?.children?.[0] as HTMLInputElement;
if (searchInput) {
searchInput.value = '';
}
// For Learn search results page
// return navigate('/search');