Skip to content

Commit

Permalink
Merge pull request #49581 from nyomanjyotisa/issue-48643
Browse files Browse the repository at this point in the history
Fix: Previous waypoints displayed for a second before new suggestions appear
  • Loading branch information
puneetlath authored Sep 23, 2024
2 parents 215a2e8 + d400ccb commit dcf1a0c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/AddressSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function AddressSearch(
const [locationErrorCode, setLocationErrorCode] = useState<GeolocationErrorCodeType>(null);
const [isFetchingCurrentLocation, setIsFetchingCurrentLocation] = useState(false);
const shouldTriggerGeolocationCallbacks = useRef(true);
const [shouldHidePredefinedPlaces, setShouldHidePredefinedPlaces] = useState(false);
const containerRef = useRef<View>(null);
const query = useMemo(
() => ({
Expand Down Expand Up @@ -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 : <Text style={[styles.textLabel, styles.colorMuted, styles.pv4, styles.ph3, styles.overflowAuto]}>{translate('common.noResultsFound')}</Text>),
Expand Down Expand Up @@ -429,6 +433,7 @@ function AddressSearch(
onInputChange: (text: string) => {
setSearchValue(text);
setIsTyping(true);
setShouldHidePredefinedPlaces(!isOffline);
if (inputID) {
onInputChange?.(text);
} else {
Expand Down

0 comments on commit dcf1a0c

Please sign in to comment.