You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Outline highlights a heading inside a closed <details> at the page bottom #5589
At the bottom of the page, the outline highlights a heading inside a closed <details> block instead of the page's last heading.
When the page bottom is reached, setActiveLink highlights the header with the largest getAbsoluteTop(). In Chrome, a heading inside a closed <details> still has an offsetParent and an offsetTop, so it isn't filtered out as NaN. Its position can even be past the end of the page, so it sorts last.
The outline highlights "Next Steps", the last visible heading. Headings that aren't rendered (!element.checkVisibility()) are skipped.
System Info
VitePress: 2.0.0-alpha.20. Not tested on the latest (2.0.0-alpha.21), but the outline code is unchanged on main.
Browser: Chrome 157, Linux
Additional context
Related: #5473. Its open PRs (#5474, #5539) remove the forced last-item selection, which hides this symptom on the page above. Hidden headings are still counted, so one whose position lands above the active line would still be highlighted.
I'd like to take this one. I checked the page from the issue in Chrome 156: all 7 headings inside the closed <details> blocks return checkVisibility() === false but still have offsets, several of them past the page height (Precedence at 12766 on a 6616px page), while Next Steps is visible.
The fix I have makes getAbsoluteTop() return NaN when element.checkVisibility?.() is false, so those headings go through the existing NaN filter in setActiveLink. Browsers without checkVisibility keep the current behavior. It also stops a heading inside a closed <details> from being picked as active mid-page, not just at the bottom. Unit tests are in outline.test.ts.
It's independent of #5474 / #5539 for #5473 (those change the bottom-of-page logic, this only changes which headings are considered), so it should apply on top of either. Does that sound OK? Happy to open a PR.
Activity
moonlorddev commentedon Nov 24, 2026
I'd like to take this one. I checked the page from the issue in Chrome 156: all 7 headings inside the closed
<details>blocks returncheckVisibility() === falsebut still have offsets, several of them past the page height (Precedenceat 12766 on a 6616px page), whileNext Stepsis visible.The fix I have makes
getAbsoluteTop()returnNaNwhenelement.checkVisibility?.()isfalse, so those headings go through the existingNaNfilter insetActiveLink. Browsers withoutcheckVisibilitykeep the current behavior. It also stops a heading inside a closed<details>from being picked as active mid-page, not just at the bottom. Unit tests are inoutline.test.ts.It's independent of #5474 / #5539 for #5473 (those change the bottom-of-page logic, this only changes which headings are considered), so it should apply on top of either. Does that sound OK? Happy to open a PR.