fix: case studies filter tabs no longer break back button#4896
Open
rahulhgdev wants to merge 1 commit into
Open
fix: case studies filter tabs no longer break back button#4896rahulhgdev wants to merge 1 commit into
rahulhgdev wants to merge 1 commit into
Conversation
|
@rahulhgdev is attempting to deploy a commit to the neondatabase Team on Vercel. A member of the Team first needs to authorize it. |
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.
What's the problem?
Clicking category filters on the case studies page was adding a new browser history entry each time. So if you clicked through a few filters and opened an article, the back button would take you through every filter you'd clicked instead of just going back to the page.
Case.Studies.Neon.mp4
Steps to reproduce
Before:
article → #ai-agents → #fast-moving-teams → #startups → /case-studiesAfter:
article → /case-studiesWhat's the fix?
When a filter is clicked, instead of letting the browser push a new history entry, we now replace the current one using
replaceState. The URL still updates so deep-linking and sharing still work - the back button just behaves correctly now.Also added a
popstatelistener alongside the existinghashchangeone. Without it, hitting back from an article wouldn't sync the active filter with the URL since back navigation firespopstate, nothashchange.File changed