Repository navigation
Pass scroll anchoring over a sidebar's leading aside to the body - #5383
Merged
Merged
Conversation
On a sidebar page whose aside comes before the body, growth above the window moved the line the user was reading by the growth's height, in Chromium and Firefox: an agent's reply in command-hub's #goal-parser thread above the screen moved the line read 90px, and Chromium logged a 0.0365 layout shift. The browser anchors on the first box in tree order that the window shows whole, or on one it shows in part when nothing inside that box qualifies. Beside the body, the aside stretches along it and holds only the sticky track, which never qualifies (`overflow-anchor: none`, and stuck), so the aside itself became the anchor and the walk stopped there. No growth in the body moves the aside's top, so the browser compensated nothing. A 90px block appended by script, with no Leaf code involved, moved the line the same way; with the aside excluded, both that block and the agent's reply left the line still in both engines, the page scrolling 90px instead. An aside before the body now carries `overflow-anchor: none`, so anchoring reaches the body, as held-news.js and geometry.js's `motionBand` already assume. This also covers windows under 480px tall, where the track flows rather than sticks but the aside still stretches past it. An aside after the body keeps anchoring: stacked under the body, its top is what moves with growth above it. Behavior changed: a sidebar body holds still for growth above the window. In a window both too narrow for the aside to stand beside the body and under 480px tall, growth inside a leading aside's flowing track above the line read there now moves that line, as it already did in taller windows, where the stuck track never anchored. Affected: every `layout-sidebar` page with its aside first, such as command-hub, pr-walkthrough, triage-board and the site's docs pages.
leaf-agent
approved these changes
Nov 4, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 5, 2026
…lds (#5397) Four renders took the reader's place away from the browser's scroll anchoring: they replaced the node anchoring held, or turned anchoring off where the reader reads. This fixes each at its render. `main`'s place keeper (`placeKeeper`) and the seat's hold (`holdBox`) are unchanged, and none of the fixes fights them. This is the first part of the places step of the cutover to one way of knowing what's on screen, after #5361 and #5392; the one hold that replaces those two (#5396) follows, once a generated test of every case lands. Pixels are `origin/main` → this branch, measured with `leaf-dev probe` in Chromium and Firefox alike unless named. ## Message words keep their nodes through an edit A message's words reconcile through `setRenderedChildren` (`thread/messages.js`, `keptWords`), the matching a revision uses, instead of a Lit `.innerHTML` binding. An edit keeps every node it leaves alone and rewrites a changed paragraph's words in place. Neither engine anchors again on a node that replaces its anchor, so the old binding lost the place on every edit. - Reply box focused and scrolled away, an edit from another tab grows the first paragraph of a message above the window: the second paragraph being read moved 126px → 0. - With that first paragraph on screen it still moves 126px: anchoring holds the paragraph that grows, and the growth is inside it. Only a hold fixes that case. - The seat's own holds are unchanged: reply box with an answer arriving above it 0 → 0, Send focused as a reply appends 0 → 0. A margin card's focused message under an edit stays at 378px, as on `main`. The matching (`dom-children.js`) diffs each list of siblings, and a diff costs the list's length times the edits between them, so an edit that changed every paragraph of a message would cost the square of its length. A new rule of the matching, `diffWork`, bounds that, and the caller chooses it: message words call `setRenderedChildren(…, {bounded: true})`, and a list whose diff would cost more than 2^18 is replaced, as `.innerHTML` replaced it. Every other caller keeps `main`'s exact matching, unbounded: authored revisions, whose nodes carry the user's state (two fallbacks tried for them each gave the read paragraph's node away in some revision `main` handles), and the Markdown file preview, which already reconciled through `setRenderedChildren`. Completing a Markdown reference definition turns a reference in every paragraph into a link: | Paragraphs | 250 | 500 | 1,000 | 2,000 | |---|---|---|---|---| | Chromium, `main` (`.innerHTML`) | 0.7ms | 1.2ms | 2.3ms | 8.8ms | | Chromium, this branch | 4.1ms | 5.7ms | 9.4ms | 19.5ms | | Firefox, `main` | 5ms | 11ms | 24ms | 57ms | | Firefox, this branch | 10ms | 15ms | 32ms | 78ms | Without the bound, Firefox took 959ms at 2,000 paragraphs. A selection in a paragraph survives an edit elsewhere in the message, where `main` drops it. ## A revision edits inside a pane `lf-pane` declares `x-patch: members`, so a revision edits inside a pane rather than replacing it whole; the module reads only which child is which. A revision adding five paragraphs above a pane's window moved its reader 0 → 0 with `main`'s landmark restore, and now the pane and its body stay the nodes the reader had. For the user, a wheel in a pane while a revision lands there is no longer cut short by the replacement. ## A sidebar track keeps its own anchoring A sidebar page's track body no longer sets `overflow-anchor: none` on its own scroller. The aside before the body keeps that property (#5383), which keeps the page's anchoring off the track. A block growing 200px above the line read in the track moved it 200px → 0. A revision adding a verdict above it stays 0 → 0 with no frame out of place, so the landmark restore and anchoring don't fight. ## The dial's glide no longer drags Firefox's anchoring The dial's gliding blocks carry `overflow-anchor: none` in their keyframes, so a block is no scroll anchor while it glides. Firefox anchors on where a box is drawn, so anchoring on a gliding block scrolled the page by its glide. With motion on, Skim then Read on the detail example: | | Chromium | Firefox | |---|---|---| | `main` | −0.2, −0.2px | 360.7, 347.9px | | this branch | −0.2, −0.2px | −0.3, −0.1px | The paragraph wrapped in an `em` lands at −0.3 and −0.1px in Firefox too. One sequence gets worse in Chromium. After a turn has glided, and before any scroll, growth above the reading line, such as an image loading, moves the paragraph read by the growth: 200px in the reviewer's probe, 0 on `main`. While the blocks glide Chromium anchors on something other than them, and keeps that anchor after the glide until the next scroll. Firefox moves in that sequence on `main` too. The trade is that rare move in Chromium for the 360px Firefox move on every dial turn with motion on; the stale anchor is the next fix. ## Tests Each new browser test fails with its fix undone. - New: `test_an_edit_above_the_paragraph_read_keeps_it_where_anchoring_holds_it` (both engines), `test_growth_above_the_window_moves_nothing_read_in_a_sidebar_track` (both engines), `test_a_turn_that_glides_keeps_the_place_in_every_engine` (both engines; Firefox's case fails without the keyframes), a runtime test that `setRenderedChildren` keeps the nodes an edit leaves, and one that a bounded rendered list of 2,000 paragraphs, every one rewritten, is replaced (without the bound it fails, after 4.7s). - Rewritten: `test_revision_restoration_yields_to_input_while_a_diagram_loads[patch-wheel]` read the pane's offset mid-glide and expected it back, which held only while a revision replaced the pane. With the pane patched in place the wheel carries on past that offset, as the user's wheel should. The test now waits for the wheel to settle and checks that what it brought into view stays where it stood; without `x-patch`, the 220px wheel never takes the pane past 300px and the test times out. > _This was written by Claude Code on behalf of max-sixty_
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
layout-sidebarpage whose aside comes before the body (command-hub, pr-walkthrough, triage-board and the site's docs pages), anything that grew above the window moved the line the user was reading by its height, in Chromium and Firefox: an agent's reply in command-hub's#goal-parserthread above the screen moved it 90px.The browser anchors on the first box in tree order that the window shows whole, or on one it shows in part when nothing inside it qualifies. Beside the body, the aside stretches along it and holds only the sticky track, which never qualifies (
overflow-anchor: none, and stuck), so the aside itself became the anchor. Growth in the body never moves the aside's top, so the browser compensated nothing. A 90px block appended by script, with no Leaf code involved, moved the line the same way; with the aside excluded, both that block and the agent's reply leave the line still in both engines.An aside before the body now carries
overflow-anchor: none, so anchoring reaches the body, asheld-news.jsandgeometry.js'smotionBandalready assume. An aside after the body keeps anchoring, since stacked under the body its top is what moves with growth above it.Behavior changed: a sidebar body holds still for growth above the window. In a window both too narrow for the aside to stand beside the body and under 480px tall, growth inside a leading aside's flowing track above the line read there now moves that line, as it already did in taller windows.
test_growth_above_the_window_moves_nothing_read_in_a_sidebar_bodyfails onmain(the line moves 103px) and passes here.