feat: keep the map viewport in the URL so a place can be shared by link - #135
Merged
Merged
Conversation
Extends the existing share state (place/city/types, already selected and centred via ?place=) with lat/lng/zoom viewport params: parseMapState restores them on load (skipping the fit-all view), a ViewportReporter mirrors pan/zoom into the URL with replaceState (no history entries), and copy-link now reproduces the exact viewport in a fresh tab. Invalid viewport params degrade to the default view instead of crashing. Closes StudentSuite#118
Contributor
|
@AryanSingh is attempting to deploy a commit to the studentsuite Team on Vercel. A member of the Team first needs to authorize it. |
yakew7
marked this pull request as ready for review
August 14, 2026 15:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #118. Sharing a specific place or view wasn't possible: opening
/mapalways landed on the default view, and reloading lost the selected place and viewport.What already existed (kept intact)
?place=<id>selects the place, opens its card, and flies to it (viaFlyToPlace);?place=nonsensefalls back to the default view.city/typesfilter params round-trip through the URL.What this PR adds
lat,lng,zoom. On load they restore that exact center/zoom instead of fitting all places.ViewportReporterinside the map mirrors pan/zoom end into the URL withhistory.replaceState— the acceptance criteria's "panning updates the URL but adds no browser history entries", so the back button still exits in one press.lat/lngonly apply when both are present and finite; a missing or bogus pair (?lat=abc) degrades to the default view without crashing.Verification
share.test.ts, including viewport round-trips, zoom-omission, and malformed-param handling).tsc --noEmit,eslint, andnext buildclean.next startsmoke test:/map,/map?lat=19.076&lng=72.8777&zoom=12,/map?place=mum-library-01,/map?place=nonsense, and/map?lat=abc&lng=72.8777all return 200 with no server errors.