Skip to content

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

Description

@chosung-dev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions