diff --git a/src/components/AddressSearch/index.tsx b/src/components/AddressSearch/index.tsx index a06c76e4f86..9c72b371c40 100644 --- a/src/components/AddressSearch/index.tsx +++ b/src/components/AddressSearch/index.tsx @@ -94,6 +94,7 @@ function AddressSearch( const [locationErrorCode, setLocationErrorCode] = useState(null); const [isFetchingCurrentLocation, setIsFetchingCurrentLocation] = useState(false); const shouldTriggerGeolocationCallbacks = useRef(true); + const [shouldHidePredefinedPlaces, setShouldHidePredefinedPlaces] = useState(false); const containerRef = useRef(null); const query = useMemo( () => ({ @@ -326,8 +327,11 @@ function AddressSearch( if (!searchValue) { return predefinedPlaces ?? []; } + if (shouldHidePredefinedPlaces) { + return []; + } return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? []; - }, [predefinedPlaces, searchValue]); + }, [predefinedPlaces, searchValue, shouldHidePredefinedPlaces]); const listEmptyComponent = useMemo( () => (!isTyping ? undefined : {translate('common.noResultsFound')}), @@ -429,6 +433,7 @@ function AddressSearch( onInputChange: (text: string) => { setSearchValue(text); setIsTyping(true); + setShouldHidePredefinedPlaces(!isOffline); if (inputID) { onInputChange?.(text); } else {