Repository navigation
Read which boxes scroll again when the window, a container or a module moves them - #1953
Merged
Merged
Conversation
…e moves them The runtime's sweep (`reachScrollers`, runtime/reach.js) decides which boxes scroll from their computed overflow, and three things hang off that answer: a keyboard tab stop, the edge marks that say more is off to one side, and the restart of the sticky-header slot `--lf-top`. Three defects shared that answer. ## A box that starts scrolling after it arrives The sweep read each box's overflow only when the box arrived or was first drawn, so a box a media query, a container query or a script turned into a scroller later got no stop, no edge marks and no restart until reload. A side-list queue narrowed from a desktop window to a phone's width showed no edge arrows on its row of tabs. The sweep now reads a box again when an input to its computed style moves: - the whole page when the window resizes; - a size container's subtree when the size its queries read changes; - a subtree a module announces with `layoutChanged`, which is how a class a page script adds reaches it. Residency (content-layout.js) now announces `main` when it seats a resident, since the Layout makes a seated sidebar scroll; a sidebar loaded in the margin had no stop. A re-read waits until what asked for it holds still, per box, and sweeps the outermost of the boxes due once, so dragging a window reads the page once when it stops rather than every frame (a sweep is about 28ms on the corpus), and no sweep runs inside a size delivery, where it raised ResizeObserver loops. A container a sweep finds is observed from the next frame for the same reason. A box is due once a frame passes without it being asked for again, and the frames it waits through are counted by the settled reading (rendering.js), so the page reads as settled only after the sweep. A container that keeps moving for longer than a second is the exception, whatever moves it (its own animation, a sibling's, a script): the page is playing, as a meter pulsing while work runs is, so its asks stop holding the page and its box waits 100ms still on a timer, holding back only its own subtree. A transition or drag that ends within the second stays counted. The container watch is an uncounted `sizeObserver` (the new `counted: false`), and a container's own asks are kept apart from the window's and a module's, so announcing a playing container still settles. A box that stops scrolling gives back the stop the sweep lent it and its restart. The restart no longer has its own watch: it is read with the declaration. A style that moves with none of these inputs, such as a rule on `:checked`, is still read only at the next one, since the browser announces nothing when it applies. ## A page tab panel the page makes scroll The tab strip stacks its height onto its panel's `--lf-top` with a selector that outranked the runtime's restart, so a diff in a panel the page made scroll pinned 113px down. The restart (`[data-lf-scrolls]`) moves from shadow.css, where it sat in the packages' layer at no specificity, to state.css, above packages and Layouts. A box that starts its slot other than at 0 says so in `--lf-top-start` (a workspace pane's body, the thread list), which the restart reads. ## An `overflow: hidden` box geometry.js counts `hidden` as a scroller for what sticky headers cover, and the sweep did not, so a hidden box held its headers without restarting the slot. The sweep and scroll-motion.js now ask geometry.js's predicate (`scrollsBy`). The undecided option card and a hidden page tab panel used `hidden` only to clip, which made the card the scroller a diff's file header in an option stuck in, so it scrolled off with the page. Both now say `overflow: clip`, and the header pins under the banner. ## Behavior that changed - A box that starts scrolling at a shorter window, a narrower container, or after a module's `layoutChanged` takes a stop, edge marks and the restart a frame after the layout settles; one that stops gives all three back. - A column sidebar loaded seated in the margin takes its tab stop. - A diff in a page tab panel the page makes scroll pins at the panel's content edge. - A diff in an undecided option pins under the banner as the page scrolls past. ## Tests - `test_a_box_that_starts_scrolling_after_it_arrives_takes_a_stop` replaces the strict xfail from #1903. It covers the window (a height query, which no box's size follows), a container, a script's class announced from inside a size delivery, a box a script inserts and announces, the window growing a box out of scrolling, a table drawn when its disclosure opens, a sidebar loaded seated in the margin, and a size container animating from load and announced once, after which the page still settles. - `test_any_box_that_scrolls_starts_the_sticky_header_slot_again` gains an `overflow: hidden` box. - `test_a_diff_pins_to_its_page_tab_panel_or_past_an_option_card` is new. - Each fails with its part of the change taken out: the resize, container and `layoutChanged` re-reads, sweeping an announcement inside the delivery, gating it on the announced box alone, residency's announcement, observing a container inside a delivery, counting the container watch, never treating a container as playing, sharing one timestamp between a container's asks and a module's, giving back the stop, the shared predicate, the restart's layer, `--lf-top-start`, and the card's `clip`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
scroll-motion.js: main exported scrollContainer and added scrollsContent with its own scrollport test; both now read geometry.js's predicate (scrollsBy, and the per-axis scrollport it is built from). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
module-authoring.md said only that a box a package makes scroll starts `--lf-top` again at 0px. It now says the runtime restarts the slot on every box that scrolls and doesn't itself stick, `overflow: hidden` included; that a padded scroller whose headers should stand on its top edge states `--lf-top-start` at minus its padding; and that a box that only clips, such as a card rounding its corners, uses `overflow: clip`, so a header inside it pins below the banner. Two eval cases score it, three Claude Code trials per arm: - `package-scroller-headers-stand-on-its-edge`: base 0/3, candidate 3/3. Every candidate states `--lf-top-start`, which is the only answer its rubric passes, since the runtime's restart replaces a package's own `--lf-top` on a scroller. - `package-card-keeps-its-headers-pinned`: base 3/3, candidate 3/3, so it guards. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 7, 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.
The runtime's scroller sweep (
reachScrollers,runtime/reach.js) decides which boxes scroll from their computed overflow. Three things depend on that answer: a keyboard tab stop, the edge marks that say more is off to one side, and the restart of the sticky-header slot--lf-top. Three defects found while landing #1902 and #1903 came from that answer, and this PR fixes all three.A box that starts scrolling after it arrives
The sweep read each box's overflow only when the box arrived or was first drawn. A box that a media query, a container query or a script turned into a scroller later got no stop, no edge marks and no restart until reload. A side-list queue narrowed from a desktop window to a phone's width showed no edge arrows on its row of tabs.
The sweep now reads a box again when an input to its computed style moves:
layoutChanged, which is how a class a page script adds reaches it.Residency (
content-layout.js) now announcesmainwhen it seats a resident, because the Layout makes a seated sidebar scroll. A sidebar loaded in the margin had no stop.A re-read waits until what asked for it holds still, per box, then sweeps the outermost due boxes once. A window drag therefore reads the page once when it stops rather than every frame (a sweep is about 28ms on the corpus). No sweep runs inside a size delivery, where it raised ResizeObserver loops.
The settled reading counts a box's wait. A container that keeps moving for longer than a second is the exception, whatever moves it. It is playing, as a meter that pulses while work runs is, so it stops holding the page and waits 100ms still on a timer. For this,
sizeObserver(rendering.js) gainedcounted: false. A box that stops scrolling gives back its stop and its restart.A style that moves with none of these inputs, such as a rule on
:checked, is read only at the next one, because the browser announces nothing when it applies.A page tab panel the page makes scroll
The tab strip stacked its height onto its panel's
--lf-topwith a selector that outranked the runtime's restart, so a diff in a panel the page made scroll pinned 113px down. The restart ([data-lf-scrolls]) moves fromshadow.css, where it sat in the packages' layer at no specificity, tostate.css, above packages and Layouts.A box whose slot starts somewhere other than 0 says so in
--lf-top-start, which the restart reads. The workspace pane body and the thread list do this.module-authoring.mdnow tells package authors about--lf-top-startandoverflow: clip. Two eval cases score that paragraph:package-scroller-headers-stand-on-its-edge: base 0/3, candidate 3/3 (Claude Code).package-card-keeps-its-headers-pinned: 3/3 on both arms, so it guards.An
overflow: hiddenboxgeometry.jscountedhiddenas a scroller when reading what sticky headers cover, and the sweep did not. The sweep,scroll-motion.js'sscrollContainerandscrollsContent(#1944), and geometry's header reading now share one predicate,scrollsBywith its per-axisscrollport.The undecided option card and a hidden page tab panel used
hiddenonly to clip. That made the card the scroller a diff's file header in an option stuck in, so the header scrolled off with the page. Both now sayoverflow: clip, and the header pins under the banner.Behavior that changed
layoutChangedtakes a stop, edge marks and the restart once the layout settles. One that stops gives all three back.Is there a more underlying fix?
Yes, and this PR makes it. The first version answered the reported cases. Review then ran other routes to the same answer, and each one failed until fixed here:
layoutChangedsent from inside a ResizeObserver callback;Merging main exposed a third copy of the scroller predicate in #1944's
scrollsContent, which now reads the shared one.Still open, each run and confirmed:
layoutChanged, waits for the next resize or announcement;--lf-top-startpins its headers below its padding.Tests
test_a_box_that_starts_scrolling_after_it_arrives_takes_a_stopreplaces Keep every tab strip to one row, so a phone opens a queue's item under it #1903's strict xfail. It covers each route above, a table drawn when its disclosure opens, a sidebar loaded seated in the margin, and a size container animating from load that a script announces, after which the page still settles.test_any_box_that_scrolls_starts_the_sticky_header_slot_againgains anoverflow: hiddenbox.test_a_diff_pins_to_its_page_tab_panel_or_past_an_option_cardis new.clip.npm run test:runtimepasses.