Preserve /people view toggle on back navigation#17057
Open
rynaco wants to merge 1 commit into
Open
Conversation
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.
Changes
Fixes a small UX issue on the
/peoplepage. I'm applying for the Technical CSM role and this will really speed up my research about the team ;)Before: From the People page, switching to the Map view, clicking a team member's profile, and then hitting the browser back button drops you back on the List view — losing the user's place.
After: The active view is persisted in the URL as
?view=map, so browser back-navigation restores the view the user came from.Considered persisting the user's pan/zoom position on the map (so back-navigation returns them to the exact spot they were looking at, not just the default view). Decided against bundling it into this PR as the implementation adds more complexity (would need moveend listeners writing to sessionStorage or extra URL params for lng/lat/zoom), and just returning to the map view (instead of resetting to list) is already a meaningful improvement by itself.
Implementation
viewquery param on mount (and on anylocation.searchchange, so browser back/forward stays in sync) and reflect it in the existingactiveTabstate.navigate(..., { replace: true })so toggling doesn't pollute history — only navigating away from/peoplecreates a back-stop.?view=listis omitted from the URL (it's the default), keeping URLs clean.URLSearchParams.set/deleterather than string replacement.Uses the same
useLocationfrom@reach/router+ gatsbynavigatepattern already used insrc/components/Editor/index.tsx,TemplatesLibrary/index.tsx, andIntegrationsLibrary/index.tsx.Checklist
vercel.json(n/a — no page moved)Verification
Verified locally with
pnpm start:/people→ List view, URL is clean/people?view=map, view switches to map/community/profiles/<id>/people?view=mapwith map view active ✓/people?view=mapopens in map view; direct load of/peopleopens in list viewreplace: true)