diff --git a/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx b/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx index 046689527..5e30ba51d 100644 --- a/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx +++ b/src/components/Search/SearchBar/searchInput/MenuWithPeople.tsx @@ -40,27 +40,33 @@ const MenuWithPeople = (props) => { return ( - {appContext.mlSearchEnabled && ( - + + {appContext.mlSearchEnabled && indexStatus && ( - {constants.PEOPLE} - {indexStatus && ( + <> + {constants.PEOPLE} {indexStatusSuggestion.label} - )} + - {people && people.length > 0 && ( + )} + {people && people.length > 0 && ( + <> + + {constants.PEOPLE} + { + onSelect={(_, index) => { props.selectRef.current.blur(); props.setValue(peopleSuggestions[index]); - }}> + }} + /> - )} - - )} + + )} + {props.children} ); diff --git a/src/components/Search/SearchBar/searchInput/index.tsx b/src/components/Search/SearchBar/searchInput/index.tsx index 1eaf51b90..499dd9abc 100644 --- a/src/components/Search/SearchBar/searchInput/index.tsx +++ b/src/components/Search/SearchBar/searchInput/index.tsx @@ -97,12 +97,10 @@ export default function SearchInput(props: Iprops) { // https://github.com/JedWatson/react-select/issues/1879 // for correct fix AsyncSelect can be extended to support default options reloading on focus/click const handleOnFocus = () => { - if (appContext.mlSearchEnabled) { - const emptySearch = ' '; - selectRef.current.state.inputValue = emptySearch; - selectRef.current.select.state.inputValue = emptySearch; - selectRef.current.handleInputChange(emptySearch); - } + const emptySearch = ' '; + selectRef.current.state.inputValue = emptySearch; + selectRef.current.select.state.inputValue = emptySearch; + selectRef.current.handleInputChange(emptySearch); }; return ( diff --git a/src/services/searchService.ts b/src/services/searchService.ts index 20c7ee81f..e77912afb 100644 --- a/src/services/searchService.ts +++ b/src/services/searchService.ts @@ -32,17 +32,22 @@ export const getAutoCompleteSuggestions = (files: EnteFile[], collections: Collection[]) => async (searchPhrase: string) => { searchPhrase = searchPhrase.trim().toLowerCase(); + const suggestions = []; + suggestions.push(await getIndexStatusSuggestion()); + suggestions.push(...(await getAllPeopleSuggestion())); if (!searchPhrase?.length) { - return []; + return suggestions; } - const suggestions = [ - ...getHolidaySuggestion(searchPhrase), - ...getYearSuggestion(searchPhrase), - ...getDateSuggestion(searchPhrase), - ...getCollectionSuggestion(searchPhrase, collections), - ...getFileSuggestion(searchPhrase, files), - ...(await getLocationSuggestions(searchPhrase)), - ]; + suggestions.push( + ...[ + ...getHolidaySuggestion(searchPhrase), + ...getYearSuggestion(searchPhrase), + ...getDateSuggestion(searchPhrase), + ...getCollectionSuggestion(searchPhrase, collections), + ...getFileSuggestion(searchPhrase, files), + ...(await getLocationSuggestions(searchPhrase)), + ] + ); const previewImageAppendedOptions: SearchOption[] = suggestions .map((suggestion) => ({ @@ -58,8 +63,8 @@ export const getAutoCompleteSuggestions = fileCount: resultFiles.length, previewFiles: resultFiles.slice(0, 3), }; - }) - .filter((option) => option.fileCount); + }); + // .filter((option) => option.fileCount); return previewImageAppendedOptions; };