From eb0ab4001d2b98ba1a70b64e6eeeca7b7c0d72ea Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 27 Jun 2026 12:02:55 +0200 Subject: [PATCH] fix(planner): show the route tools for a single place when optimizing from accommodation (#1330) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The day's route tools were gated on having 2+ stops, so a day with one located place and accommodation optimization on hid them — even though the map already draws the hotel -> place -> hotel route. Treat a lone located place as routable when a bookend hotel with coordinates exists, mirroring what the map renders. Purely additive to the existing 2+ case. --- .../src/components/Planner/DayPlanSidebar.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/src/components/Planner/DayPlanSidebar.tsx b/client/src/components/Planner/DayPlanSidebar.tsx index 029f9233..892945a3 100644 --- a/client/src/components/Planner/DayPlanSidebar.tsx +++ b/client/src/components/Planner/DayPlanSidebar.tsx @@ -1055,6 +1055,9 @@ function useDayPlanSidebar(props: DayPlanSidebarProps) { const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarProps) { const S = useDayPlanSidebar(props) + // Needed by the route-tools visibility gate in the render below (#1330); the hook + // keeps its own copy, so read it reactively here in the component scope too. + const optimizeFromAccommodation = useSettingsStore(s => s.settings.optimize_from_accommodation) const { tripId, trip, @@ -1240,6 +1243,16 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP const cost = dayTotalCost(day.id, assignments, currency) const formattedDate = formatDate(day.date, locale) const loc = da.find(a => a.place?.lat && a.place?.lng) + // Route tools normally need 2+ stops, but a single located place is still + // routable when accommodation optimization can bookend it with a hotel + // (hotel → place → hotel, the same line the map draws) — otherwise the tools + // vanish on such a day (#1330). Purely additive to the 2+ case. + const routeBookends = optimizeFromAccommodation !== false ? getDayBookendHotels(day, days, accommodations) : null + const hasRouteBookend = !!( + (routeBookends?.morning?.place_lat != null && routeBookends?.morning?.place_lng != null) || + (routeBookends?.evening?.place_lat != null && routeBookends?.evening?.place_lng != null) + ) + const routeToolsRoutable = da.length >= 2 || (loc != null && hasRouteBookend) const isDragTarget = dragOverDayId === day.id const merged = mergedItemsMap[day.id] || [] const dayNoteUi = noteUi[day.id] @@ -2163,8 +2176,8 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP )} - {/* Routen-Werkzeuge (ausgewählter Tag, 2+ Orte) */} - {(isSelected || (showRouteToolsWhenExpanded && isExpanded)) && getDayAssignments(day.id).length >= 2 && ( + {/* Routen-Werkzeuge (ausgewählter Tag, 2+ Orte — oder 1 Ort mit Hotel-Bookend, #1330) */} + {(isSelected || (showRouteToolsWhenExpanded && isExpanded)) && routeToolsRoutable && (