fix(docs): fix sidebar scrollIntoView selecting last item erroneously#728
Merged
avivkeller merged 2 commits intonodejs:mainfrom Apr 4, 2026
Merged
fix(docs): fix sidebar scrollIntoView selecting last item erroneously#728avivkeller merged 2 commits intonodejs:mainfrom
avivkeller merged 2 commits intonodejs:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
avivkeller
approved these changes
Mar 30, 2026
avivkeller
reviewed
Mar 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
linkvariable 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
activeLinkvariable remainsnulland the function exits early with areturn, preventing the scrollbar from moving.Validation
Just try accessing the website (/docs/latest/api/) with this change.
Related Issues
None.
Check List
node --run testand all tests passed.node --run format&node --run lint.