fix: implement proper browser back button navigation for SPA#188
Open
Sendi0011 wants to merge 1 commit intoSnouzy:mainfrom
Open
fix: implement proper browser back button navigation for SPA#188Sendi0011 wants to merge 1 commit intoSnouzy:mainfrom
Sendi0011 wants to merge 1 commit intoSnouzy:mainfrom
Conversation
- Add URL synchronization to Zustand store using History API - Sync workout builder step with URL query parameter (?step=1,2,3) - Add popstate event listener to handle browser back/forward buttons - Replace window.location.href with router.push in signup flow - Replace window.location.reload with router.refresh in admin modals - Initialize store with step from URL on page load This ensures the back button navigates between workout builder steps instead of exiting the application entirely. Fixes Snouzy#80
|
@Sendi0011 is attempting to deploy a commit to the Workoutcool Team 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.
📝 Description
Fixes the back button navigation issue where clicking the browser's back button would exit the site instead of navigating to the previous step within the workout builder.
Problem
The workout builder uses Zustand for state management, which only stores state in memory. When users navigate through steps (Equipment → Muscles → Exercises), no browser history entries are created. This causes the back button to exit the application entirely instead of going to the previous step.
Solution
?step=1,?step=2,?step=3popstateevent listener to handle back/forward button clicksChanges Made
Main Fix:
workout-builder.store.tsto sync with browser historyupdateURL()helper to push history statesgetStepFromURL()to read initial state from URLpopstateevent listener for back/forward navigationsetStep,nextStep,prevStep,loadFromSessionmethodsAdditional Improvements:
useSignUp.ts- replacedwindow.location.hrefwithrouter.push()window.location.reload()withrouter.refresh()create-program-modal.tsxadd-session-modal.tsxadd-week-modal.tsxTechnical Details
pushState,popstate)windowbefore accessing browser APIs📋 Checklist
🗃️ Prisma Migrations (if applicable)
📸 Screenshots (if applicable)
Testing completed:
?step=1,?step=2,?step=3/workout-builder?step=2)🔗 Related Issues
Closes #80