#2549·TREK

[BUG] Public share link map opens zoomed into a fraction of the trip's area until a day filter is toggled

Author: FlightkickCreated Sep 28, 2026Updated Sep 28, 2026

Pre-flight checklist

  • I have searched existing issues and this bug has not been reported yet
  • I am running the latest available version of TREK
  • I have read the Troubleshooting guide and my issue is not covered there

TREK version 4.3.3

Describe the bug When opening a trip's public share link, the map section does not frame the whole trip. It opens zoomed in tightly on a small cluster of the trip's places. After selecting a specific day in the day filter and then switching back to "All", the map correctly zooms out and positions itself to show the full overview of the trip. The correct framing only ever appears after toggling the day filter; it never appears on the initial load.

Steps to reproduce

  1. Create a trip whose places span roughly a county/small-region-sized area (my case: about a dozen places with coordinates spread over a small geographic area, several of them clustered within a few hundred meters of each other).
  2. Enable the public share link for the trip (with the Map section visible).
  3. Open the share link in an unauthenticated/private browser window.
  4. Observe the map: it is zoomed in on a small part of the trip's area, centred on the dense cluster of places.
  5. Click any specific day in the day filter above the map, then click "All" again.
  6. The map now frames the entire trip correctly.

Expected behavior The map on a public share link should open framed on all of the trip's located places, the same view it ends up showing after toggling the day filter back to "All". The initial framing should not depend on toggling the day filter first.

Deployment method Docker Compose

Host OS N/A

Accessing TREK from Desktop browser (also reproduced on mobile browser; the effect is strongest on desktop)

Browser (if applicable) N/A

Relevant logs or error output None — no console or server errors. This is a purely client-side map view (centre + zoom) framing issue.

Screenshots None available.

Additional context I traced this in the client source (current main):

  • client/src/pages/SharedTripPage.tsx (~line 189) computes the map's opening view with computeMapViewport(...) but passes no width/height.
  • client/src/utils/mapViewport.ts (defaultWidth/defaultHeight, ~lines 193–203) then falls back to window.innerWidth/window.innerHeight, so the opening zoom is computed as if the map filled the whole browser viewport — while the actual map card is a fixed 300 px tall box on the page (SharedTripPage.tsx ~line 429).
  • The FitBoundsToPlaces component (SharedTripPage.tsx ~lines 74–93, mounted at ~line 452 with framedOnMount={framed !== null}) deliberately skips its initial map.fitBounds when it believes the map already opened framed correctly. Because of the mismatch above, that assumption is false and nothing corrects the zoom.
  • Toggling a day and back changes the place set, which re-keys the effect; since fitRan.current is then already true, the guard no longer applies and map.fitBounds runs against the real container size — producing the correct framing.

Effect in numbers for my trip's geometry: the places frame at roughly zoom 12.9 when computed for a ~1080 px-tall window, versus roughly zoom 10.6 for the actual ~300 px-tall card — the difference between "a small part of the destination" and "full overview". The larger the browser window relative to the map card, the more pronounced the over-zoom; on mobile the effect is smaller because the window and card heights are closer.

Suggested direction for a fix (not a hard requirement): measure the map card's real container size (ref + clientWidth/clientHeight, or a ResizeObserver) and pass it into computeMapViewport as width/height, so the mount framing matches what fitBounds would produce and the framedOnMount guard holds. Hardcoding dimensions would not be robust; the container-driven measurement works across desktop and mobile browsers.