Skip to content

doc: add scroll margin to links #58982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

silverwind
Copy link
Contributor

Before: Opening a section link like this one would hide the section title behind the sticky stability header:

Screenshot 2025-07-07 at 15 45 46

After: Page scroll is offset by 50px so the section header is visible:

Screenshot 2025-07-07 at 15 45 57

The value change is undone below 600px where it is not an issue because the page header is not sticky.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/nodejs-website

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

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

No port needed, the change causing this has not been ported.

@silverwind
Copy link
Contributor Author

silverwind commented Jul 7, 2025

One issue: Links in sections without sticky stability header like this one are incorrectly offset. This is likely tricky to fix in CSS, but I will try.

Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

LGMT !

@silverwind
Copy link
Contributor Author

silverwind commented Jul 7, 2025

Fixed that issue, seems to work everywhere now. It only offsets the scroll on pages where there is a module-level stability header (outside the <section> elements).

@aduh95 aduh95 marked this pull request as draft July 7, 2025 21:41
@aduh95 aduh95 marked this pull request as ready for review July 7, 2025 21:41
@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Jul 7, 2025
@dario-piotrowicz dario-piotrowicz added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Jul 8, 2025
@@ -373,6 +373,11 @@ p {
padding-bottom: 2rem;
}

/* prevent the module-level sticky stability header from overlapping the section headers when clicked */
#apicontent:has(> .api_stability) a {
Copy link
Member

@dario-piotrowicz dario-piotrowicz Jul 8, 2025

Choose a reason for hiding this comment

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

this means that every single a of every single page that has an api stability banner will receive the scroll-margin-top attribute.... is that correct? cause the comment above suggests to me that this is only specific for headers? 🤔

Copy link
Contributor Author

@silverwind silverwind Jul 8, 2025

Choose a reason for hiding this comment

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

It means every page that has a top-level stability banner. The docs HTML layout is like this:

<div id="apicontent">
  <div class="api-stability"></div>
  <a></a>
  <section>
    <div class="api-stability"></div>
    <a></a>
  </section>
</div>

On some pages like the errors page, the first api-stability is missing, so it won't work on the section stabilities there, for example https://nodejs.org/api/errors.html#err_cpu_usage.

Honestly I think this is not completely solveable from CSS and would prefer if the sticky headers would be removed. This is a best-effort solution that should work in 99% of cases. I hear the docs will be re-written so maybe this is fine as an interim solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants