diff --git a/client/src/pages/TripPlannerPage.tsx b/client/src/pages/TripPlannerPage.tsx index b8b5dc50..abecfdc5 100644 --- a/client/src/pages/TripPlannerPage.tsx +++ b/client/src/pages/TripPlannerPage.tsx @@ -233,9 +233,19 @@ export default function TripPlannerPage(): React.ReactElement | null { const [showReservationModal, setShowReservationModal] = useState(false) const [editingReservation, setEditingReservation] = useState(null) const [fitKey, setFitKey] = useState(0) + const initialFitTripId = useRef(null) const [mobileSidebarOpen, setMobileSidebarOpen] = useState<'left' | 'right' | null>(null) const [deletePlaceId, setDeletePlaceId] = useState(null) + useEffect(() => { + if (!trip) return + if (initialFitTripId.current === trip.id) return + const hasGeoPlaces = places.some(p => p.lat != null && p.lng != null) + if (!hasGeoPlaces) return + initialFitTripId.current = trip.id + setFitKey(k => k + 1) + }, [trip, places]) + const connectionsStorageKey = tripId ? `trek:visible-connections:${tripId}` : null const [visibleConnections, setVisibleConnections] = useState(() => { if (typeof window === 'undefined' || !connectionsStorageKey) return []