From e4065c276b25f695b8e14db7a2427934925438ed Mon Sep 17 00:00:00 2001 From: mauriceboe Date: Sat, 4 Apr 2026 20:26:24 +0200 Subject: [PATCH] fix(map,lightbox): center map above day detail panel and fix lightbox close - Map pans up when DayDetailPanel is open so route markers aren't hidden - Files lightbox: clicking dark background closes lightbox again - Memories lightbox: clicking dark background closes lightbox again --- client/src/components/Files/FileManager.tsx | 5 +++-- client/src/components/Map/MapView.tsx | 21 ++++++++++++------- .../src/components/Memories/MemoriesPanel.tsx | 3 ++- client/src/pages/TripPlannerPage.tsx | 1 + 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/client/src/components/Files/FileManager.tsx b/client/src/components/Files/FileManager.tsx index e27b53f..dbaefa7 100644 --- a/client/src/components/Files/FileManager.tsx +++ b/client/src/components/Files/FileManager.tsx @@ -120,9 +120,10 @@ function ImageLightbox({ files, initialIndex, onClose }: ImageLightboxProps) { {/* Main image + nav */} -
e.stopPropagation()}> +
{ if (e.target === e.currentTarget) onClose() }}> {navBtn('left', goPrev, hasPrev)} - {imgSrc && {file.original_name}} + {imgSrc && {file.original_name} e.stopPropagation()} />} {navBtn('right', goNext, hasNext)}
diff --git a/client/src/components/Map/MapView.tsx b/client/src/components/Map/MapView.tsx index a3ff1bb..32d1ec4 100644 --- a/client/src/components/Map/MapView.tsx +++ b/client/src/components/Map/MapView.tsx @@ -161,12 +161,13 @@ function MapController({ center, zoom }: MapControllerProps) { // Fit bounds when places change (fitKey triggers re-fit) interface BoundsControllerProps { + hasDayDetail?: boolean places: Place[] fitKey: number paddingOpts: Record } -function BoundsController({ places, fitKey, paddingOpts }: BoundsControllerProps) { +function BoundsController({ places, fitKey, paddingOpts, hasDayDetail }: BoundsControllerProps) { const map = useMap() const prevFitKey = useRef(-1) @@ -176,9 +177,14 @@ function BoundsController({ places, fitKey, paddingOpts }: BoundsControllerProps if (places.length === 0) return try { const bounds = L.latLngBounds(places.map(p => [p.lat, p.lng])) - if (bounds.isValid()) map.fitBounds(bounds, { ...paddingOpts, maxZoom: 16, animate: true }) + if (bounds.isValid()) { + map.fitBounds(bounds, { ...paddingOpts, maxZoom: 16, animate: true }) + if (hasDayDetail) { + setTimeout(() => map.panBy([0, 150], { animate: true }), 300) + } + } } catch {} - }, [fitKey, places, paddingOpts, map]) + }, [fitKey, places, paddingOpts, map, hasDayDetail]) return null } @@ -377,17 +383,18 @@ export const MapView = memo(function MapView({ leftWidth = 0, rightWidth = 0, hasInspector = false, + hasDayDetail = false, }) { - // Dynamic padding: account for sidebars + bottom inspector + // Dynamic padding: account for sidebars + bottom inspector + day detail panel const paddingOpts = useMemo(() => { const isMobile = typeof window !== 'undefined' && window.innerWidth < 768 if (isMobile) return { padding: [40, 20] } const top = 60 - const bottom = hasInspector ? 320 : 60 + const bottom = hasInspector ? 320 : hasDayDetail ? 280 : 60 const left = leftWidth + 40 const right = rightWidth + 40 return { paddingTopLeft: [left, top], paddingBottomRight: [right, bottom] } - }, [leftWidth, rightWidth, hasInspector]) + }, [leftWidth, rightWidth, hasInspector, hasDayDetail]) // photoUrls: only base64 thumbs for smooth map zoom const [photoUrls, setPhotoUrls] = useState>(getAllThumbs) @@ -509,7 +516,7 @@ export const MapView = memo(function MapView({ /> - 0 ? dayPlaces : places} fitKey={fitKey} paddingOpts={paddingOpts} /> + 0 ? dayPlaces : places} fitKey={fitKey} paddingOpts={paddingOpts} hasDayDetail={hasDayDetail} /> diff --git a/client/src/components/Memories/MemoriesPanel.tsx b/client/src/components/Memories/MemoriesPanel.tsx index 7cf18cb..5b5357d 100644 --- a/client/src/components/Memories/MemoriesPanel.tsx +++ b/client/src/components/Memories/MemoriesPanel.tsx @@ -902,10 +902,11 @@ export default function MemoriesPanel({ tripId, startDate, endDate }: MemoriesPa )} -
e.stopPropagation()} style={{ display: 'flex', gap: 16, alignItems: 'flex-start', justifyContent: 'center', padding: 20, width: '100%', height: '100%' }}> +
{ if (e.target === e.currentTarget) closeLightbox() }} style={{ display: 'flex', gap: 16, alignItems: 'flex-start', justifyContent: 'center', padding: 20, width: '100%', height: '100%' }}> e.stopPropagation()} style={{ maxWidth: (!isMobile && lightboxInfo) ? 'calc(100% - 280px)' : '100%', maxHeight: '100%', objectFit: 'contain', borderRadius: 10, cursor: 'default' }} /> diff --git a/client/src/pages/TripPlannerPage.tsx b/client/src/pages/TripPlannerPage.tsx index d490dea..3f02c42 100644 --- a/client/src/pages/TripPlannerPage.tsx +++ b/client/src/pages/TripPlannerPage.tsx @@ -598,6 +598,7 @@ export default function TripPlannerPage(): React.ReactElement | null { leftWidth={leftCollapsed ? 0 : leftWidth} rightWidth={rightCollapsed ? 0 : rightWidth} hasInspector={!!selectedPlace} + hasDayDetail={!!showDayDetail && !selectedPlace} />