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 #1589

Conversation

noobpiyush
Copy link
Contributor

Fix: Back Button Scroll Position Reset

Problem

Currently, in Production, clicking the back button in the navbar 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 and implemented scroll position management to preserve the exact scroll location when users click the back button. This aligns with expected browser behavior and improves 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 testing branch.
  2. Go to any long content page.
  3. Scroll down partially.
  4. Click back button in navbar.
  5. Verify scroll position is maintained.

Notes

  • No new dependencies added.
  • No breaking changes.
  • Maintains existing functionality.
  • Only affects 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. added linting to all files
@noobpiyush noobpiyush closed this Nov 28, 2024
@noobpiyush noobpiyush deleted the fixing/remembering-scrollbar-position branch November 28, 2024 16:08
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.

1 participant