mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix: Clear search input of home page on search (#52353)
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user