Skip to content

fix(docs): fix sidebar scrollIntoView selecting last item erroneously#728

Merged
avivkeller merged 2 commits intonodejs:mainfrom
Botato300:main
Apr 4, 2026
Merged

fix(docs): fix sidebar scrollIntoView selecting last item erroneously#728
avivkeller merged 2 commits intonodejs:mainfrom
Botato300:main

Conversation

@Botato300
Copy link
Copy Markdown
Contributor

Description

Problem: Currently, when you go to: https://nodejs.org/docs/latest/api/. the scrollbar in the side menu automatically scrolls all the way to the bottom; it should only scroll automatically when a module is selected. The problem was that when there was no match, the link variable would retain the last item in the array, which is why it would scroll the scrollbar all the way to the bottom.

Solution: Simply change how the match is detected and the for-of loop: if no match is found, the activeLink variable remains null and the function exits early with a return, preventing the scrollbar from moving.

Validation

Just try accessing the website (/docs/latest/api/) with this change.

Related Issues

None.

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@Botato300 Botato300 requested a review from a team as a code owner March 30, 2026 01:02
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Apr 3, 2026 1:58am

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.17%. Comparing base (e45645a) to head (19d7cda).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #728   +/-   ##
=======================================
  Coverage   77.17%   77.17%           
=======================================
  Files         153      153           
  Lines       13771    13771           
  Branches     1114     1114           
=======================================
  Hits        10628    10628           
  Misses       3139     3139           
  Partials        4        4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@avivkeller avivkeller merged commit 2680e84 into nodejs:main Apr 4, 2026
19 checks passed
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