Skip to content

Bug: Sidebar scrolls to top on navigation, losing user's position #451

@codeEvolveZenith345

Description

@codeEvolveZenith345

Bug Description

Clicking on sidebar navigation items causes the sidebar to scroll back to the top, making the selected item disappear from view. This disrupts user experience as users lose their position in the navigation.

Steps to Reproduce

  1. Navigate to documentation page (e.g., https://volcano.sh/en/docs/)
  2. Scroll down in the sidebar to view items below the fold
  3. Click on any sidebar item
  4. Observe: Sidebar scrolls to top, clicked item is no longer visible

Expected Behavior

The sidebar should maintain its scroll position after clicking an item, keeping the selected element in view.

Actual Behavior

Sidebar resets to top position on every navigation, forcing users to scroll again to find their location.

Root Cause

  1. Sidebar re-renders on page load without preserving scroll position
  2. JavaScript bug in change() function: uses assignment (=) instead of comparison (==)
  3. Loop condition i <= ull.length +1 causes array overflow

Affected Files

  • themes/academic/layouts/partials/docs_sidebar.html

Fix Applied

  • Added sessionStorage to preserve scroll position across page loads
  • Fixed comparison operator bug (===)
  • Fixed loop bounds (i <= ull.length +1i < ull.length)

Environment

  • Browser: All browsers
  • Hugo Theme: Academic
  • Occurs on both local development and production (volcano.sh)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions