Pull Request Overview
- Opened on September 17, 2026
- Status Merged
- Commit count 1 with first commit September 17, 2026
Total Delta
Open Days
Test Delta
How long has this pull request spent in each phase of its lifecycle?
Data pending calculation for pull request
fix(tableOfContents): highlight the heading the click scrolled to
Closes JS-9876.
Clicking an item in the Table of contents scrolled to the right heading but highlighted its neighbour β the previous one in most cases, the next one near the bottom of the page.
Root cause
Two different reference lines were used for the same thing:
-
U.Dom.scrollToHeaderparks the clicked headingJ.Size.header + 20= 72px below the top of the scroll container, so it clears the sticky page header. - The highlight in
component/page/elements/tableOfContents.tsxmarked a heading current only once its top passed the container's top edge (0) β 72px higher than where the click parks it. The clicked heading never qualified, so the last one that did, the previous heading, stayed current.
The "next one" case is the bottom of the page: scrollTop >= maxScrollHeight forced the last heading regardless of which item was clicked, and tail headings that map to the same clamped scroll position fire no scroll event at all, so the highlight never moved.
Fix
-
U.Dom.getHeaderScrollOffset()is the single anchor, used both to scroll to a heading and to decide which one is current. -
U.Dom.getActiveHeaderIndex(tops, anchor)β pure helper, the last heading at or above the anchor, the first as fallback β replaces the inline edge test. - A click pins its own target through the
tableOfContents{ns}ref and holds it until the page is scrolled away from it, which covers the bottom of the page and the clicks that produce no scroll event.
All three entry points go through scrollToHeader, so the hover menu, the right sidebar panel and the in-document Table of contents block are fixed together.
Tests
src/ts/lib/util/dom.test.ts β 5 regression tests for the detection rule, including a heading parked exactly at the anchor; they fail against the old edge test. Full suite unchanged otherwise (90 pre-existing failures before and after), typecheck and lint clean. Verified in the app.
PR was closed without comments.