Skip to content

Keep the contents map on a long route by leaving its deepest levels off it - #6699

Merged
max-sixty merged 2 commits into
mainfrom
toc-unhover-fade
Nov 22, 2026
Merged

max-sixty merged 2 commits into
mainfrom
toc-unhover-fade

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

On a route whose labels don't fit down the contents map even a line each, the map now leaves its deepest level of sections off, then the next, until the rest fit; where even the top level doesn't fit, as many top-level sections stay as fit, spread from the first to the last. On main such a route gave up its map: a bare rule at rest, and a scrolling outline when revealed. A section off the map, whether left off for room or under a heading in a closed disclosure, counts its threads, On Me items and changes on the marker above it, as a heading past max-level already does; on main a hidden heading's marks showed nowhere.

main this branch
at rest main at rest: a bare vertical rule this branch at rest: a marker per top-level section on the spine
revealed main revealed: a scrolling outline of every section and subsection this branch revealed: each top-level label beside its marker, subsections left off

The labels also move into one layer apart from the markers, placed by arithmetic on the document's scale rather than laid out as flex rows and read back. On a 500-section route a reveal on main ran one 68–73 ms frame in Chromium; now its style pass takes 0.7 ms, against 0.5 ms on 20 sections. The outline's scroll machinery (scrub, scroll alignment, focus memory) goes with the outline.

Where to look: #fitLabels in lf-toc.js; data-lf-toc-shown, which the widget takes off the labels and markers it leaves off the map, so the reveal switches the pointer on the labels that show alone; and a decision the diff carries: a link left off the map leaves the Tab order and the accessibility tree too, so a screen reader's "On this page" list holds only the levels shown. Heading navigation still reaches every section.

Max picked this form from three built alternatives on a live Leaf page; Codex and a fresh Claude reviewer each reviewed it. New browser tests cover dropping a level, a hidden heading's thread, and keeping as many top-level sections as fit.

This was written by Claude Code on behalf of max-sixty

…ff it

Where a route's labels don't fit down the map even a line each, the map now
leaves its deepest level of sections off, then the next, until the rest fit,
trying each level at full size before a line each. Where even the top level
doesn't fit, as many of its sections stay as fit, spread evenly from the first
to the last. On `main` such a route gave up its map: a bare rule at rest, and a
list that scrolled when revealed. The user picked this form over three built
alternatives that kept every section on the map: a scrolling list of every
label, the same list following the pointer, and labels for the levels that fit
with the rest on hover.

A section off the map, its heading hidden or no room left for it, counts its
threads, On Me items and changes in the row above it, as a heading past
`max-level` does; the user agreed to this for the sections left off for room.
On `main` a heading inside a closed disclosure kept its marks on its own
marker, which the map hid, so they showed nowhere. Both kinds of section are
now hidden one way, with `visibility: hidden`, so the next fit can still
measure a label without showing it: the widget takes `data-lf-toc-shown`, which
every label and marker is drawn with, off those it leaves off the map.

The labels also stand in one layer apart from the markers. Markers stand on the
spine; `.lf-toc-labels` fades as one box; each row is placed by arithmetic on
the document's scale rather than by laying out flex rows and reading them back.
On a 500-section route each reveal on `main` ran one long animation frame of
68-73 ms in Chromium (3 of 3). Now the reveal's style pass takes 0.7 ms on 500
sections against 0.5 ms on 20: the layer's own `pointer-events` stays fixed, since every
label inherits it, and the paper's `::before` and the shown labels take the
pointer instead. Switching the layer's setting measured 4.4 ms on 500 sections.
Markers render by position, since the widget writes their place and state by
index, so a heading whose key changes keeps its marker.

Forced colours: top-level rings keep their CanvasText border, which the ring's
own border rule outranked once markers became their own elements.

Tests: the scrolling-outline tests (a route taller than the map, an outline
keeping its reading position) give way to tests of dropping a level, of a
thread under a heading in a closed disclosure marking the row above, and of
keeping as many top-level sections as fit; the live-title test runs on 12
sections without the outline's scroll position; the title-group test drops the
start row's span, which the link's href already covers. Reads of a row's
`::before`, `--lf-toc-span`, `--lf-toc-row-shift`, a link's opacity and
`data-lf-toc-hidden` move to the markers, `--lf-toc-reach`, the labels layer and
`data-lf-toc-shown`.
@max-sixty
max-sixty merged commit 0b4255d into main Nov 22, 2026
6 checks passed
@max-sixty
max-sixty deleted the toc-unhover-fade branch November 22, 2026 01:52
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