Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preserve scroll position on navbar back button #1592

Closed

Conversation

noobpiyush
Copy link
Contributor

Fix: Back Button Scroll Position Reset

Problem

Clicking the back button in the navbar currently causes the page to scroll back to the top, losing the user's previous scroll position. This disrupts the user experience when navigating back from content pages.

Solution

Modified the Navbar component to include scroll position management. The implementation preserves the exact scroll location when users click the back button, matching expected browser behavior and improving navigation UX.


Scroll Management Implementation

  • Added scroll position tracking
  • Implemented position restoration
  • Added browser navigation handling

Testing Done

  • Back button preserves scroll position
  • Works on both short and long pages
  • Tested on mobile devices
  • Verified with different navigation patterns

Steps to Test

  1. Checkout the testing branch.
  2. Navigate to any long content page.
  3. Scroll down partially.
  4. Click the back button in the navbar.
  5. Verify that the scroll position is maintained.

Notes

  • No new dependencies added.
  • No breaking changes introduced.
  • Existing functionality remains unaffected.
  • Changes only impact scroll behavior on back navigation.

Updates navbar back navigation to maintain scroll position when returning
to previous page. Prevents unwanted scroll reset and improves UX.

Add scroll position tracking
Modify back button handler
Implement position restoration
@devsargam
Copy link
Collaborator

i feel this is just a bit of over engineering rather than having a good dx. closing this pr now but feel free to contribute on anything else.

@devsargam devsargam closed this Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants