From b7ff12c584b4e4ff68edf9b47e306ac44fa1cd70 Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Mon, 23 Sep 2024 09:28:51 +0800 Subject: [PATCH 1/2] Fix: Previous waypoints displayed for a second before new suggestions appear --- src/components/AddressSearch/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/AddressSearch/index.tsx b/src/components/AddressSearch/index.tsx index a06c76e4f869..077814cb376b 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( () => ({ @@ -325,6 +326,8 @@ function AddressSearch( const filteredPredefinedPlaces = useMemo(() => { if (!searchValue) { return predefinedPlaces ?? []; + } else if (shouldHidePredefinedPlaces) { + return []; } return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? []; }, [predefinedPlaces, searchValue]); @@ -429,6 +432,7 @@ function AddressSearch( onInputChange: (text: string) => { setSearchValue(text); setIsTyping(true); + setShouldHidePredefinedPlaces(!isOffline); if (inputID) { onInputChange?.(text); } else { From d400ccbc5598f304d0daf485c295c003f6f114a9 Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Mon, 23 Sep 2024 11:35:43 +0800 Subject: [PATCH 2/2] minor fix --- src/components/AddressSearch/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/AddressSearch/index.tsx b/src/components/AddressSearch/index.tsx index 077814cb376b..9c72b371c40f 100644 --- a/src/components/AddressSearch/index.tsx +++ b/src/components/AddressSearch/index.tsx @@ -326,11 +326,12 @@ function AddressSearch( const filteredPredefinedPlaces = useMemo(() => { if (!searchValue) { return predefinedPlaces ?? []; - } else if (shouldHidePredefinedPlaces) { + } + if (shouldHidePredefinedPlaces) { return []; } return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? []; - }, [predefinedPlaces, searchValue]); + }, [predefinedPlaces, searchValue, shouldHidePredefinedPlaces]); const listEmptyComponent = useMemo( () => (!isTyping ? undefined : {translate('common.noResultsFound')}),