GitbookIO / GitbookIO/gitbook

Sidebar does not scroll the active page into view on client-side navigation

Open
#4,461 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
29k
Forks
4k
Avg merge
1d 2h
Merged PRs (30d)
71

Description

Bug description

On a published GitBook site, when navigating between pages via search or in-sidebar links (client-side / SPA navigation), the left sidebar correctly expands the active page's group and highlights the active item, but it does NOT scroll the sidebar's internal scroll container to bring the active item into view. The sidebar keeps its previous scroll position, so the highlighted current page is often below the fold and the user has to scroll the sidebar manually to see where they are.

On a full page reload the sidebar does scroll the active item into view correctly — the problem is specific to client-side navigation.

Reproducible on GitBook's own docs (docs.gitbook.com), latest Chrome, desktop.

Image

How to reproduce

  1. Open https://docs.gitbook.com/getting-started/quickstart
    (sidebar is at the top, "Quickstart" highlighted, scrollTop = 0).
  2. Open the search box, search "visitor authentication", and click the "Authentication" result (Documentation › Your docs site › Embed in your product) — a page located far down the same sidebar tree.
  3. Observe: the page loads and "Authentication" becomes the active page, but the sidebar's scroll position is unchanged — it still shows the top of the tree. The highlighted active item is off-screen and you must scroll the sidebar manually to find it.

Measured evidence: the sidebar scroll container's scrollTop stayed at 0 before and after navigation (scrollHeight ~2731, clientHeight ~530). The active item's bounding rect was at ~817px, below the ~806px viewport — i.e. off-screen.

Additional context

Expected: on client-side navigation, scroll the active sidebar item into view(as already happens on a full page reload).

This looks adjacent to the in-flight sidebar-during-navigation work in #4404 (TOC groups losing expand/active state) and #4391 (first item cut off after navigation), but neither of those addresses the scroll position of the active item.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the search-result navigation described in the issue and trace the sidebar’s client-side navigation path, comparing it with the full-reload behavior. The work is complete when navigating to a distant page moves the sidebar so the active item is visible, while expansion and highlighting still work as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.