Skip to content

Commit

Permalink
COMPENF-865 (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
barrfalk authored Sep 19, 2023
1 parent 69303b9 commit 33390c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getWildlifeComplaintByComplaintIdentifierSetUpdate,
selectComplaint,
setComplaint,
setComplaintLocation,
updateAllegationComplaint,
updateWildlifeComplaint,
} from "../../../store/reducers/complaints";
Expand Down Expand Up @@ -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]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const LeafletMapWithPoint: FC<Props> = ({ 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) {
Expand Down

0 comments on commit 33390c4

Please sign in to comment.