Skip to content

[Bug]: Category landing pages smooth-scroll to footer on load in WebKit/Safari #45322

Closed

Description

@schimanko

Code of Conduct

What article on docs.github.com is affected?

Summary

When navigating directly to category landing pages or short-link redirects in WebKit/Safari, the browser automatically performs a smooth scroll animation all the way down to the footer upon initial load/reload.

Steps to Reproduce

  1. Open Safari.
  2. Navigate directly to https://docs.github.com/en/account-and-profile.
  3. Allow the page to hydrate or reload the page (Cmd + R or Cmd + Option + R).
  4. Observe the viewport smoothly animating down to the footer (~1000px+).

Expected Behavior

The viewport should remain anchored at the very top (scrollTop = 0) if I entered the page directly.

Actual Behavior

The page executes a smooth-scroll animation down to the footer.

Screen.Recording.2026-07-27.at.17.34.09.mov

What changes are you suggesting?

Possible root cause

Primer CSS applies scroll-behavior: smooth; unconditionally on html. During Next.js client-side hydration, as document height expands while WebKit handles initial scroll restoration, WebKit's smooth-scroll animation miscalculates target progress relative to the shifting DOM height and animates the viewport down to the bottom. In other words, Safari's a mess.

Possible fix

I have identified a fix in src/frame/stylesheets/index.scss by scoping scroll-behavior: smooth to html:focus-within and am ready to submit a PR linking to this issue.

Additional information

Reproducible URLs

  • https://docs.github.com/en/account-and-profile
  • https://docs.github.com/copilot (redirects to /en/copilot)

Browser / Environment

  • Browser: Safari / WebKit (macOS 26.3.1 & iOS 27.0 Beta)
  • Engine: WebKit

Activity

  1. added
    contentThis issue or pull request belongs to the Docs Content team
    on Jul 27, 2026
  2. added
    triageDo not begin working on this issue until triaged by the team
    on Jul 27, 2026
  3. schimanko commented on Jul 27, 2026

    @schimanko
    Author

    PR Details

    For maintainers looking to resolve this:

    Root Cause:

    Primer CSS applies scroll-behavior: smooth; unconditionally to html. During Next.js client-side hydration in Safari/WebKit, as the document height expands while WebKit handles initial scroll restoration, WebKit's smooth-scroll engine miscalculates the target scroll progress relative to the shifting DOM height and animates the viewport all the way down to the footer (~1000px+).

    Verified Fix:

    Overriding scroll-behavior: auto !important; on html and scoping scroll-behavior: smooth to html:focus-within in src/frame/stylesheets/index.scss resolves the autoscroll bug completely on page load while preserving smooth scrolling for anchor links (#section-id) and keyboard navigation:

    /* Prevent WebKit smooth-scroll hydration bug on page load */
    html {
      scroll-behavior: auto !important;
    }
    
    /* Enable smooth scrolling when navigating via keyboard or anchor links */
    html:focus-within {
      scroll-behavior: smooth;
    }

    I closed #45323 since external contributions to src/** aren't accepted per repository policy.

  4. Sharra-writes commented on Aug 6, 2026

    @Sharra-writes
    Contributor

    @schimanko This is site functionality, not documentation, so we can't handle it from this repository. This will have to go through the support team.

  5. spacexm406-web commented on Sep 1, 2026

    @spacexm406-web

    Yes you have full permission

  6. locked as spam and limited conversation to collaborators on Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentThis issue or pull request belongs to the Docs Content teamtriageDo not begin working on this issue until triaged by the team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions