The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix: stale closure in updateRouteForDay causes route to disappear on place click
Luca41bfcf2f765b
diff --git a/client/src/hooks/useRouteCalculation.ts b/client/src/hooks/useRouteCalculation.tsindex e78c3fb65..60ce403b1 100644--- a/client/src/hooks/useRouteCalculation.ts+++ b/client/src/hooks/useRouteCalculation.ts@@ -15,11 +15,14 @@ export function useRouteCalculation(tripStore: TripStoreState, selectedDayId: nuconst [routeSegments, setRouteSegments] = useState<RouteSegment[]>([])const routeCalcEnabled = useSettingsStore((s) => s.settings.route_calculation) !== falseconst routeAbortRef = useRef<AbortController | null>(null)+ // Keep a ref to the latest tripStore so updateRouteForDay never has a stale closure+ const tripStoreRef = useRef(tripStore)+ tripStoreRef.current = tripStoreconst updateRouteForDay = useCallback(async (dayId: number | null) => {if (routeAbortRef.current) routeAbortRef.current.abort()if (!dayId) { setRoute(null); setRouteSegments([]); return }- const currentAssignments = tripStore.assignments || {}+ const currentAssignments = tripStoreRef.current.assignments || {}const da = (currentAssignments[String(dayId)] || []).slice().sort((a, b) => a.order_index - b.order_index)const waypoints = da.map((a) => a.place).filter((p) => p?.lat && p?.lng)if (waypoints.length < 2) { setRoute(null); setRouteSegments([]); return }