diff --git a/frontend/src/app/components/containers/complaints/complaint-details.tsx b/frontend/src/app/components/containers/complaints/complaint-details.tsx index b3c7879a9..019c43611 100644 --- a/frontend/src/app/components/containers/complaints/complaint-details.tsx +++ b/frontend/src/app/components/containers/complaints/complaint-details.tsx @@ -8,6 +8,7 @@ import { getWildlifeComplaintByComplaintIdentifierSetUpdate, selectComplaint, setComplaint, + setComplaintLocation, updateAllegationComplaint, updateWildlifeComplaint, } from "../../../store/reducers/complaints"; @@ -47,6 +48,7 @@ export const ComplaintDetails: FC = () => { //-- when the component unmounts clear the complaint from redux return () => { dispatch(setComplaint(null)); + dispatch(setComplaintLocation(null)); }; }, [dispatch]); diff --git a/frontend/src/app/components/mapping/leaflet-map-with-point.tsx b/frontend/src/app/components/mapping/leaflet-map-with-point.tsx index 6e633bfeb..f1fa2218f 100644 --- a/frontend/src/app/components/mapping/leaflet-map-with-point.tsx +++ b/frontend/src/app/components/mapping/leaflet-map-with-point.tsx @@ -25,6 +25,14 @@ const LeafletMapWithPoint: FC = ({ coordinates, draggable, onMarkerMove } const [markerPosition, setMarkerPosition] = useState<{ lat: number; lng: number }>(coordinates); + // update the marker poisition when the coordinates are updated (occurs when geocoded). + // but don't update them if the marker position has already been set manually + useEffect(() => { + if (markerPosition.lat === 0 && markerPosition.lng === 0) { + setMarkerPosition(coordinates); + } + }, [coordinates, markerPosition.lat, markerPosition.lng]); + const handleMarkerDragEnd = (e: L.LeafletEvent) => { const marker = e.target; if (marker?.getLatLng) {