From fef7ac4587e09201f240dcd637f673edc40d27ae Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 27 Nov 2026 20:05:59 +0100 Subject: [PATCH] fix(map): set the trip overview aside for the visit instead of switching it off Making room for the day details went through the overview's remembered switch, which the account keeps per trip and syncs to every device. A day sheet on the phone, or two cards that did not fit on a narrow window, turned the overview off everywhere without the traveller touching the pill. The overview is now set aside for this visit only: the remembered switch stays as it was, the pill shows it off and brings it back with one tap, and a reload shows it again. The route overview hook keeps its declared return type with the new hasPlannedRoute flag. --- .../components/Map/useTripRouteOverview.ts | 5 +++- .../useTripPlanner.overview.test.tsx | 23 +++++++++++++++++++ .../src/pages/tripPlanner/useTripPlanner.ts | 15 ++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/client/src/components/Map/useTripRouteOverview.ts b/client/src/components/Map/useTripRouteOverview.ts index fff6d9d3f..61b20745a 100644 --- a/client/src/components/Map/useTripRouteOverview.ts +++ b/client/src/components/Map/useTripRouteOverview.ts @@ -17,6 +17,9 @@ export interface TripRouteOverview extends TripRouteSummary { loading: boolean } +/** The overview as the planner reads it: also whether the trip has any stop to route at all. */ +type PlannedTripRouteOverview = TripRouteOverview & { hasPlannedRoute: boolean } + const EMPTY: TripRouteOverview = { ...summariseTripRoute([]), loading: false } const EMPTY_PLACES: Place[] = [] @@ -49,7 +52,7 @@ export function useTripRouteOverview( vias?: TripRouteVias, /** MDT-02: where the stages of the trip's multi-day tours run, so a day holding one draws that stage. */ tourStageStops?: TourStageStops, -) { +): PlannedTripRouteOverview { const optimizeFromAccommodation = useSettingsStore(s => s.settings.optimize_from_accommodation) const toursEnabled = useTripAddonEnabled(tripId, 'tours') // Leg text is formatted at compute time, so a km↔mi switch has to re-run (#1300). diff --git a/client/src/pages/tripPlanner/useTripPlanner.overview.test.tsx b/client/src/pages/tripPlanner/useTripPlanner.overview.test.tsx index 438012158..bb6153eaa 100644 --- a/client/src/pages/tripPlanner/useTripPlanner.overview.test.tsx +++ b/client/src/pages/tripPlanner/useTripPlanner.overview.test.tsx @@ -115,4 +115,27 @@ describe('useTripPlanner: showing the whole trip', () => { }); expect(result.current.overviewActive).toBe(false); }); + + it('puts the overview away for this visit only, the remembered switch stays on and the pill brings it back', async () => { + const { result } = await renderPlanner({ selectedDayId: day.id }); + const remembered = () => useSettingsStore.getState().settings.planner_trip_views?.['42']?.overview; + + act(() => { + result.current.toggleOverview(); + }); + expect(remembered()).toBe(true); + act(() => { + result.current.hideOverview(); + }); + expect(result.current.overviewShown).toBe(false); + expect(result.current.overviewActive).toBe(false); + expect(remembered()).toBe(true); + + act(() => { + result.current.toggleOverview(); + }); + expect(result.current.overviewShown).toBe(true); + expect(result.current.overviewActive).toBe(true); + expect(remembered()).toBe(true); + }); }); diff --git a/client/src/pages/tripPlanner/useTripPlanner.ts b/client/src/pages/tripPlanner/useTripPlanner.ts index eca3c1695..83cf734b4 100644 --- a/client/src/pages/tripPlanner/useTripPlanner.ts +++ b/client/src/pages/tripPlanner/useTripPlanner.ts @@ -370,22 +370,27 @@ export function useTripPlanner() { } = plannerDialogs const { mapLocked, toggleMapLocked, mapLockedRef, isMobileRef, fitKey, setFitKey, - overviewShown, toggleOverview: toggleMapOverview, dawarichTrailShown, toggleDawarichTrail, dawarichTrail, + overviewShown: overviewRemembered, toggleOverview: toggleMapOverview, dawarichTrailShown, toggleDawarichTrail, dawarichTrail, routeShown, setRouteShown, autoShowRoute, transitRoutesShown, routeProfile, setRouteProfile, } = usePlannerMapView({ tripId, trip, places, selectedDayId, isMobile }) + // Making room for the day details puts the overview away for this visit only: + // the switch the account remembers stays on, and the pill brings it back. + const [overviewSetAsideFor, setOverviewSetAsideFor] = useState(null) + const overviewShown = overviewRemembered && overviewSetAsideFor !== tripId // Road trip mode draws its own overview. const overviewActive = overviewShown && !roadtripMode const hideOverview = useCallback(() => { - if (overviewActive) toggleMapOverview() - }, [overviewActive, toggleMapOverview]) + if (overviewActive) setOverviewSetAsideFor(tripId) + }, [overviewActive, tripId]) const setShowDayDetail = useCallback((day: Day | null) => { stashedDayDetailRef.current = null setDayDetail(day) }, []) const toggleOverview = useCallback(() => { if (!overviewShown) stashedDayDetailRef.current = null - toggleMapOverview() - }, [overviewShown, toggleMapOverview]) + if (overviewRemembered && !overviewShown) setOverviewSetAsideFor(null) + else toggleMapOverview() + }, [overviewShown, overviewRemembered, toggleMapOverview]) const [mobileSidebarOpen, setMobileSidebarOpen] = useState<'left' | 'right' | null>(null) const mobilePlanScrollTopRef = useRef(0) const mobilePlacesScrollTopRef = useRef(0)