Repository navigation
Keep the contents map on a long route by leaving its deepest levels off it - #6699
Merged
Merged
Conversation
…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`.
leaf-agent
approved these changes
Nov 22, 2026
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.
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
mainsuch 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 pastmax-levelalready does; onmaina hidden heading's marks showed nowhere.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
mainran 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:
#fitLabelsinlf-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.