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
feat(collections): the map's padlock, and a picked place on the full map keeps the map
Mauriceb65a1bb65cc4
diff --git a/client/src/components/Collections/CollectionMap.tsx b/client/src/components/Collections/CollectionMap.tsxindex 7a5d6e201..f912e1792 100644--- a/client/src/components/Collections/CollectionMap.tsx+++ b/client/src/components/Collections/CollectionMap.tsx@@ -15,6 +15,9 @@ interface CollectionMapProps {dark: boolean/** A control bar floats over the top of the map (the desktop panel's), so the frame starts below it. */underBar?: boolean+ /** Given, the padlock sits on the map: locked, picking a place leaves the camera where it is (#2010). */+ locked?: boolean+ onToggleLock?: () => void}/** How far a pin reaches from its point: half a selected pin (44 px) and the rating badge on its corner. */@@ -69,7 +72,7 @@ function framePoints(places: CollectionPlace[]): [number, number][] {* box instead, clear of the edges and of the controls floating over it, and lands* while the map is built rather than flying in.*/-export default function CollectionMap({ places, selectedPlaceId, onOpenPlace, onDeselect, dark, underBar = false }: CollectionMapProps): React.ReactElement {+export default function CollectionMap({ places, selectedPlaceId, onOpenPlace, onDeselect, dark, underBar = false, locked = false, onToggleLock }: CollectionMapProps): React.ReactElement {const pts = useMemo(() => mappablePlaces(places).map(withMarkerCategory), [places])const tileUrl = useTileUrl(dark ? OFM_DARK : OFM_POSITRON)const focusPoints = useMemo(() => framePoints(pts), [pts])@@ -95,6 +98,8 @@ export default function CollectionMap({ places, selectedPlaceId, onOpenPlace, onfocusPoints={focusPoints}focusKey={focusKey}fitPadding={framePadding(underBar)}+ followSelection={!locked}+ onToggleFollow={onToggleLock}/></div>)diff --git a/client/src/components/Collections/CollectionMapPanel.tsx b/client/src/components/Collections/CollectionMapPanel.tsxindex a3ec7214a..146e7d13f 100644--- a/client/src/components/Collections/CollectionMapPanel.tsx+++ b/client/src/components/Collections/CollectionMapPanel.tsx@@ -28,6 +28,9 @@ interface CollectionMapPanelProps {onLabelFilter?: (ids: number[]) => voidcanManageLabels?: booleanonManageLabels?: () => void+ /** The padlock on the desktop map (#2010); the phone has no hover to look around with. */+ mapLocked?: boolean+ onToggleMapLocked?: () => voidt: TranslationFn}@@ -39,7 +42,7 @@ interface CollectionMapPanelProps {export default function CollectionMapPanel({places, selectedPlaceId, onSelect, onDeselect, dark, overlay, view, onToggleView,search, onSearch, labelOptions = [], labelFilter = [], onLabelFilter, canManageLabels = false,- onManageLabels, t,+ onManageLabels, mapLocked = false, onToggleMapLocked, t,}: CollectionMapPanelProps): React.ReactElement {const showLabels = onLabelFilter != null && (labelOptions.length > 0 || canManageLabels)return (@@ -51,6 +54,8 @@ export default function CollectionMapPanel({onDeselect={onDeselect}dark={dark}underBar={overlay}+ locked={overlay && mapLocked}+ onToggleLock={overlay ? onToggleMapLocked : undefined}/>{overlay && (<div className="col-map-topbar">diff --git a/client/src/hooks/useMapLock.ts b/client/src/hooks/useMapLock.tsnew file mode 100644index 000000000..77f973c2b--- /dev/null+++ b/client/src/hooks/useMapLock.ts@@ -0,0 +1,30 @@+import { useCallback, useState } from 'react';++const MAP_LOCK_KEY = 'trek:map-locked';++/**+ * Whether a map keeps its camera when a place or a day is picked (#2010). One+ * setting per browser for every map that offers the padlock, the trip planner+ * and the collections alike: whoever locked one expects the other to hold still too.+ */+export function useMapLock(): [boolean, () => void] {+ const [locked, setLocked] = useState<boolean>(() => {+ try {+ return localStorage.getItem(MAP_LOCK_KEY) === '1';+ } catch {+ return false;+ }+ });+ const toggle = useCallback(() => {+ setLocked((prev) => {+ const next = !prev;+ try {+ localStorage.setItem(MAP_LOCK_KEY, next ? '1' : '0');+ } catch {+ /* private mode keeps it for the session */+ }+ return next;+ });+ }, []);+ return [locked, toggle];+}diff --git a/client/src/pages/CollectionsPage.test.tsx b/client/src/pages/CollectionsPage.test.tsxindex 42658d5e4..e191adcd5 100644--- a/client/src/pages/CollectionsPage.test.tsx+++ b/client/src/pages/CollectionsPage.test.tsx@@ -59,6 +59,10 @@ function makeHook(overrides: Record<string, unknown> = {}) {heroHeight: 0,listColRef: { current: null },listColRect: null,+ mapColRef: { current: null },+ mapColRect: null,+ mapLocked: false,+ toggleMapLocked: vi.fn(),categories: [],collections: [{ id: 1, name: 'Test', is_owner: true }],ownedLists: [{ id: 1, name: 'Test', is_owner: true }],diff --git a/client/src/pages/CollectionsPage.tsx b/client/src/pages/CollectionsPage.tsxindex 2d40dcf99..47bb876fd 100644--- a/client/src/pages/CollectionsPage.tsx+++ b/client/src/pages/CollectionsPage.tsx@@ -73,11 +73,16 @@ function CollectionsPageDesktop(): React.ReactElement {if (c.view !== 'map') c.setSelectedPlaceId(null)c.setView(c.view === 'map' ? 'list' : 'map')}- // Clicking a marker in the full-map view drops back to the split so the list- // + detail come into view alongside the map.- const onMapSelect = (id: number) => { showPlace(id); if (c.view === 'map') c.setView('list') }+ // A marker shows its place and the map stays as it is: on the full map the+ // detail docks on the map's edge instead of bringing the list back.+ const onMapSelect = (id: number) => showPlace(id)const desktopSplit = c.isWide && c.hasMappable+ // Where the place detail docks: over the list in the split, on the map's start+ // edge when the map has the whole width, and as a centred sheet otherwise.+ const detailDock = !desktopSplit ? null+ : c.view === 'map' ? (c.mapColRect ? { left: c.mapColRect.left + 12, width: Math.min(420, c.mapColRect.width - 24) } : null) // rtl-lint-disable: a measured viewport position, like the list dock+ : c.listColRectconst mapShown = c.hasMappable && (c.view === 'map' || c.isWide)const mapOverlay = c.isWide && mapShown // the map carries the toggle + searchconst canAddPlace = typeof c.activeId === 'number' && c.canEdit // a real list you can edit@@ -112,6 +117,8 @@ function CollectionsPageDesktop(): React.ReactElement {onToggleView={toggleView}search={c.search}onSearch={c.setSearch}+ mapLocked={c.mapLocked}+ onToggleMapLocked={c.toggleMapLocked}t={t}/>)@@ -184,7 +191,7 @@ function CollectionsPageDesktop(): React.ReactElement {body = (<div className={`col-split${c.view === 'map' ? ' map-full' : ''}`}><div className="col-split-list" ref={c.listColRef}>{listColumn}</div>- <div className="col-split-map">{mapPanel(true)}</div>+ <div className="col-split-map" ref={c.mapColRef}>{mapPanel(true)}</div></div>)} else if (c.view === 'map' && c.hasMappable) {@@ -343,14 +350,14 @@ function CollectionsPageDesktop(): React.ReactElement {visible + interactive). On the desktop split it docks over the listcolumn so the map stays clear; otherwise it's a full-width sheet.Clicking another place / the map background re-points the selection. */}- {c.selectedPlace && c.view !== 'map' && (+ {c.selectedPlace && (c.view !== 'map' || c.hasMappable) && (<CollectionPlaceDetailplace={c.selectedPlace}canEdit={c.canEdit}canDelete={c.canDelete}categories={c.categories}labels={c.labels}- anchorRect={desktopSplit ? c.listColRect : null}+ anchorRect={detailDock}onClose={c.handleCloseDetail}onSetStatus={c.handleDetailStatus}onSave={patch => c.updatePlace(c.selectedPlace!.id, patch)}diff --git a/client/src/pages/CollectionsPage.wiring.test.tsx b/client/src/pages/CollectionsPage.wiring.test.tsxindex ac7c72266..8bb468ef0 100644--- a/client/src/pages/CollectionsPage.wiring.test.tsx+++ b/client/src/pages/CollectionsPage.wiring.test.tsx@@ -4,7 +4,7 @@// to the hook. The page follows the Page pattern, so useCollections is mocked and// each child is stubbed with a prop-driven button.import React from 'react'-import { render, screen, fireEvent } from '../../tests/helpers/render'+import { render, screen, fireEvent, cleanup } from '../../tests/helpers/render'import CollectionsPage from './CollectionsPage'vi.mock('../components/Layout/Navbar', () => ({ default: () => <nav data-testid="navbar" /> }))@@ -59,8 +59,10 @@ vi.mock('../components/Collections/CollectionFilterBar', () => ({}))vi.mock('../components/Collections/CollectionMapPanel', () => ({- default: (p: { overlay: boolean; places: { id: number }[]; onSelect: (id: number) => void; onDeselect: () => void; onToggleView: () => void; onSearch: (v: string) => void; onLabelFilter?: (ids: number[]) => void; onManageLabels?: () => void }) => (+ default: (p: { overlay: boolean; places: { id: number }[]; onSelect: (id: number) => void; onDeselect: () => void; onToggleView: () => void; onSearch: (v: string) => void; onLabelFilter?: (ids: number[]) => void; onManageLabels?: () => void; mapLocked?: boolean; onToggleMapLocked?: () => void }) => (<div data-testid={p.overlay ? 'map-overlay' : 'map-plain'}>+ <span data-testid="map-locked">{String(p.mapLocked)}</span>+ {p.onToggleMapLocked && <button type="button" onClick={p.onToggleMapLocked}>map-lock</button>}<span data-testid="map-count">{p.places.length}</span><span data-testid="map-has-labels">{String(p.onLabelFilter != null)}</span>{p.onManageLabels && <button type="button" onClick={p.onManageLabels}>map-labels</button>}@@ -192,6 +194,10 @@ function makeHook(overrides: Hook = {}): Hook {heroHeight: 240,listColRef: () => {},listColRect: { left: 10, width: 400 },+ mapColRef: () => {},+ mapColRect: { left: 500, width: 900 },+ mapLocked: false,+ toggleMapLocked: vi.fn(),categories: [],collections: [list],ownedLists: [list, { id: 4, name: 'Other', is_owner: true }],@@ -556,11 +562,18 @@ describe('CollectionsPage — child wiring', () => {expect(hook.setView).toHaveBeenCalledWith('map')})- it('FE-PAGE-COLLPAGE-028: from the map view a marker click drops back into the split', () => {+ it('FE-PAGE-COLLPAGE-028: on the full map a marker click shows the place and the map stays', () => {const hook = renderPage({ view: 'map' })fireEvent.click(screen.getByText('map-select'))expect(hook.setSelectedPlaceId).toHaveBeenCalledWith(10)- expect(hook.setView).toHaveBeenCalledWith('list')+ expect(hook.setView).not.toHaveBeenCalled()+ })++ it('FE-PAGE-COLLPAGE-028b: the map carries the trip map\'s padlock, remembered by the page', () => {+ const hook = renderPage({ mapLocked: true })+ expect(screen.getByTestId('map-locked')).toHaveTextContent('true')+ fireEvent.click(screen.getByText('map-lock'))+ expect(hook.toggleMapLocked).toHaveBeenCalledTimes(1)})it('FE-PAGE-COLLPAGE-029: the map view toggle returns to the list without clearing the selection', () => {@@ -637,9 +650,17 @@ describe('CollectionsPage — detail sheet and modals', () => {expect(screen.getByTestId('detail-anchored')).toHaveTextContent('sheet')})- it('FE-PAGE-COLLPAGE-034: the full-map view hides the detail sheet', () => {+ it('FE-PAGE-COLLPAGE-034: on a narrow full map the detail opens as a sheet over the map', () => {renderPage({ ...withPlace, view: 'map', isWide: false })- expect(screen.queryByTestId('detail')).toBeNull()+ expect(screen.getByTestId('detail-anchored')).toHaveTextContent('sheet')+ })++ it('FE-PAGE-COLLPAGE-034b: on a wide full map the detail docks on the map\'s edge, once the map is measured', () => {+ renderPage({ ...withPlace, view: 'map' })+ expect(screen.getByTestId('detail-anchored')).toHaveTextContent('docked')+ cleanup()+ renderPage({ ...withPlace, view: 'map', mapColRect: null })+ expect(screen.getByTestId('detail-anchored')).toHaveTextContent('sheet')})it('FE-PAGE-COLLPAGE-035: the add-place modal is bound to the active list', () => {diff --git a/client/src/pages/collections/useCollections.ts b/client/src/pages/collections/useCollections.tsindex 137f4413b..83dc48f41 100644--- a/client/src/pages/collections/useCollections.ts+++ b/client/src/pages/collections/useCollections.ts@@ -3,6 +3,7 @@ import { useNavigate, useParams, useSearchParams } from 'react-router'import { useTranslation } from '../../i18n'import { useElementSize } from '../../hooks/useElementSize'import { useElementRect } from '../../hooks/useElementRect'+import { useMapLock } from '../../hooks/useMapLock'import { useSettingsStore } from '../../store/settingsStore'import { useAuthStore } from '../../store/authStore'import { useToast } from '../../components/shared/Toast'@@ -52,6 +53,10 @@ export function useCollections() {const hero = useElementSize<HTMLDivElement>()// Measure the split's list column so the place-detail sheet can dock over it.const listCol = useElementRect<HTMLDivElement>()+ // ...and the map column, so on a full map the sheet docks on the map's own edge.+ const mapCol = useElementRect<HTMLDivElement>()+ // The trip map's padlock (#2010): a locked map stays put when a place is picked.+ const [mapLocked, toggleMapLocked] = useMapLock()const store = useCollectionStore()const {@@ -556,7 +561,8 @@ export function useCollections() {return {t, language, dark, navigate,isWide, heroRef: hero.ref, heroHeight: hero.height,- listColRef: listCol.ref, listColRect: listCol.rect, categories,+ listColRef: listCol.ref, listColRect: listCol.rect, mapColRef: mapCol.ref, mapColRect: mapCol.rect, categories,+ mapLocked, toggleMapLocked,// store datacollections, ownedLists, sharedLists, activeCollection, isAllSaved, isOwner,myRole, canEdit, canDelete,diff --git a/client/src/pages/tripPlanner/usePlannerMapView.ts b/client/src/pages/tripPlanner/usePlannerMapView.tsindex dbd2ab107..13f613f27 100644--- a/client/src/pages/tripPlanner/usePlannerMapView.ts+++ b/client/src/pages/tripPlanner/usePlannerMapView.ts@@ -4,6 +4,7 @@ import { usePlannerTripView } from './usePlannerTripView'import type { TripStoreState } from '../../store/tripStore'import type { Place } from '../../types'import type { PlannerBase } from './plannerTypes'+import { useMapLock } from '../../hooks/useMapLock'interface PlannerMapViewOptions extends Pick<PlannerBase, 'tripId' | 'trip'> {places: Place[]@@ -60,20 +61,11 @@ export function usePlannerMapView(options: PlannerMapViewOptions) {// A locked map stays where the traveller put it (#2010): picking a day or a place no// longer zooms or pans it. Remembered per browser, like the other view toggles; the// first frame of a trip still fits, or the map would open on nothing.- const [mapLocked, setMapLocked] = useState<boolean>(() => {- try { return localStorage.getItem('trek:map-locked') === '1' } catch { return false }- })+ const [mapLocked, toggleMapLocked] = useMapLock()const mapLockedRef = useRef(mapLocked)mapLockedRef.current = mapLockedconst isMobileRef = useRef(isMobile)isMobileRef.current = isMobile- const toggleMapLocked = useCallback(() => {- setMapLocked(prev => {- const next = !prev- try { localStorage.setItem('trek:map-locked', next ? '1' : '0') } catch { /* private mode keeps it for the session */ }- return next- })- }, [])// The recorded route from Dawarich (#2279), per trip and remembered on the// account for the same reason as the overview above: it answers "what// actually happened on this trip", a question about one trip rather than a