Skip to content

Fix scrolling issue breaking navigation on certain pages.#2104

Closed
bgravenorst wants to merge 3 commits intomainfrom
fixScrolling
Closed

Fix scrolling issue breaking navigation on certain pages.#2104
bgravenorst wants to merge 3 commits intomainfrom
fixScrolling

Conversation

@bgravenorst
Copy link
Contributor

Description

The right sidebar Table of Contents (TOC) links were not working properly on some pages. When users clicked on TOC links, the page would scroll to the correct section but then immediately jump back to the top, making navigation unusable.

Root Cause

The issue was in src/client/scroll-fix.js where an overly aggressive window.scrollTo(0, 0) call was resetting the page scroll position after every route change. This interfered with:

  • TOC anchor link navigation
  • Direct anchor link navigation
  • User's intended scroll position

Solution

Removed the window.scrollTo(0, 0) call from the scroll-fix logic while preserving the intended sidebar visibility functionality.

Preview

Checklist

Complete this checklist before merging your PR:

  • If this PR contains a major change to the documentation content, I have added an entry to the top of the "What's new?" page.
  • The proposed changes have been reviewed and approved by a member of the documentation team.

Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
Copilot AI review requested due to automatic review settings June 18, 2025 23:59
@bgravenorst bgravenorst requested review from a team as code owners June 18, 2025 23:59
@vercel
Copy link

vercel bot commented Jun 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
metamask-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2025 0:08am

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a scrolling issue that broke navigation by removing an unnecessary call to window.scrollTo(0, 0) that was interfering with TOC and anchor link navigation.

  • Removed the scroll reset call in the scroll-fix logic to preserve user scroll position.
  • Simplified scroll handling logic for better navigation functionality.
Comments suppressed due to low confidence (1)

src/client/scroll-fix.js:12

  • Consider adding a comment near this change to clarify that the window.scrollTo(0, 0) call was intentionally removed to prevent overriding user scroll position for TOC and anchor link navigation.
      item.scrollIntoView({ block: 'start', inline: 'nearest' })

Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
@bgravenorst
Copy link
Contributor Author

Fixed in #2103

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