Skip to content

Commit dcf1a0c

Browse files
authoredSep 23, 2024··
Merge pull request #49581 from nyomanjyotisa/issue-48643
Fix: Previous waypoints displayed for a second before new suggestions appear
2 parents 215a2e8 + d400ccb commit dcf1a0c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/components/AddressSearch/index.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function AddressSearch(
9494
const [locationErrorCode, setLocationErrorCode] = useState<GeolocationErrorCodeType>(null);
9595
const [isFetchingCurrentLocation, setIsFetchingCurrentLocation] = useState(false);
9696
const shouldTriggerGeolocationCallbacks = useRef(true);
97+
const [shouldHidePredefinedPlaces, setShouldHidePredefinedPlaces] = useState(false);
9798
const containerRef = useRef<View>(null);
9899
const query = useMemo(
99100
() => ({
@@ -326,8 +327,11 @@ function AddressSearch(
326327
if (!searchValue) {
327328
return predefinedPlaces ?? [];
328329
}
330+
if (shouldHidePredefinedPlaces) {
331+
return [];
332+
}
329333
return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
330-
}, [predefinedPlaces, searchValue]);
334+
}, [predefinedPlaces, searchValue, shouldHidePredefinedPlaces]);
331335

332336
const listEmptyComponent = useMemo(
333337
() => (!isTyping ? undefined : <Text style={[styles.textLabel, styles.colorMuted, styles.pv4, styles.ph3, styles.overflowAuto]}>{translate('common.noResultsFound')}</Text>),
@@ -429,6 +433,7 @@ function AddressSearch(
429433
onInputChange: (text: string) => {
430434
setSearchValue(text);
431435
setIsTyping(true);
436+
setShouldHidePredefinedPlaces(!isOffline);
432437
if (inputID) {
433438
onInputChange?.(text);
434439
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.