Repository navigation
Read a sticky box at its own place when seating a margin pin - #5211
Merged
Merged
Conversation
A margin pin on a block holding a sticky header takes a different seat depending on where the document was scrolled at the layout pass: while the header sticks far down the block, the seat by the block's top reads clear; scrolled back, the header's control covers it, and the next unrelated pass moves the pin with no input. This fails on main.
Collaborator
Author
|
@max-sixty, this PR is red only because of its own reproduction, |
max-sixty
added a commit
that referenced
this pull request
Nov 4, 2026
…lot below it (#5389) Since #5228 a page may put its own site header beside `main`, and Leaf doesn't know such a header is there. On a page that fixes or sticks one to the window's top: - a fragment link, `m`, `t` or Go to lands its target under the header; - a block's Copy, a heading's link, a recording's bar and a margin pin draw over the header once their block scrolls under it, since Leaf's interface stacks above every page box; - Leaf's own sticky boxes (a page tab strip, `lf-dial`, a diff's file header) stick under it; - a pin on the header's own words, seated by a margin pass made while the page was scrolled, can take a seat above the window and stay there. The same happens with such a header inside `main`, so this is not new with #5228, only more common. ## What changes Leaf already has one reading of what covers the top of a scroller: the sticky-header slot, `--lf-top`. Leaf's sticky boxes stick at it, and it feeds the margin a landing keeps (`surfaces.css`), what the user sees (`headerInset` in `geometry.js`) and the frames Leaf's marks and controls pass under (`headerLevels` in `css-anchors.js`). A header the page wrote was missing from it, which is the one cause of the first three symptoms. `browser/runtime/root-headers.js` now owns the headers over the document: those packages register (`registerRootHeader`, moved from `page-layout.js`) and the page's own. How far down the window the page's own headers reach is written as `--lf-page-head`, which `base.css` adds to the slot for everything in `body` but those headers. A header counts when it spans the middle of the column, reaches less than halfway down the window, and is one of: - a box fixed in the window that the browser's hit test finds at the window's top, however the markup nests it; - a fixed or sticky child of `body` or of a box around `main`, before `main`, or a fixed one after it, as a framework renders a header at the end of `body`; - a fixed or sticky box in `main`'s leading run, up to the first box that takes room in its flow, so a skip link, an empty anchor or a hidden sprite before the header doesn't hide it. Where several stand, as a progress bar fixed over a header does, the deepest reach counts. What stands above a sticky header, such as a banner over a sticky nav, keeps the root's slot, since it has scrolled away by the time the nav sticks. A header Leaf already counts stays with its owner, so Leaf's own headers stack below the page's. Headers are read with the document's layout, and again when one resizes, when a scroll of the document ends, and when the transitions or animations running on them finish, so a header that hides or slides in on scroll is read once it has arrived. Each reading is one hit test and the children of each box from `body` to the Layout's, so nothing runs per page element. **Landing room.** Headers raise the slot only. Their landing room comes from the zero-specificity margin every box reads from the slot, which a page's own `scroll-margin-top` replaces. **The pin on the header's words** had a separate cause: seating read the room around a pin as though everything on the page scrolled with it. A pin in a box that stands still in the window (a fixed box, or one of these headers) now reads only that box and seats within the window, and a pin on the page no longer counts what stands still as taken. The margin already kept this rule for a pane. ## Contract changes `page-layout.md` told authors to give targets `scroll-margin-top` for a fixed site header. It now says which headers need no landing room, that a taller one or one further into `main` still needs it, that a page's own `scroll-margin-top` replaces Leaf's room, and that a `scroll-padding-top` on the page's root has no effect. `module-scroll-and-motion.md`, "Headers over the document", describes the page's headers. ## Choices - **Found rather than declared.** A declaration would cost every page a rule its agent can miss, and a page written as an ordinary website has none. - **Leaf owns the root's `scroll-padding-top`** (`!important`). Otherwise a page's own root padding for its header adds to the margin Leaf now keeps. The cost: a page that clears a header Leaf doesn't read with `html { scroll-padding-top }`, such as a sticky toolbar after the title inside `main`, now lands under it, at 22px against 82px on the base. The same page clearing it with `scroll-margin-top` still lands clear. No page in `examples/` or `docs/` uses root padding. The maintainer picked this over reading the page's computed padding at runtime. - **A drawer fixed at the top under half the window's height counts while it is open**, since it does cover that band. A tighter limit would misjudge tall phone headers. ## Not fixed - In Firefox, a pin on a sticky header's words moves with the page once the header sticks, until the next margin pass puts it back (`notes/browser-support.md`, "A stuck sticky anchor in Firefox"). The base does the same. A fixed header's pin holds in both engines. - A sticky header further into `main`, or inside a section, isn't read. #5211's header is one, and its pin's seat still depends on where the header was stuck when the pass ran. ## Testing An independent reviewer used the change in Chromium and Firefox on fixtures for each case above, and on pages that must not count: a cookie banner at the foot, a fixed sidebar, a small fixed box at the top left, a sticky table head, sticky section headings, and `lf-dial` first in `main` on a phone. Its findings are fixed here. After merging `main`: `tests/browser/test_page_head.py` (2 tests, 12 subtests) and the ten tests that read the slot, landings and pin seating (`test_independent_document_headers_contribute_measured_landing_room`, `test_a_flowing_workspace_keeps_its_header_over_what_a_next_lands_on`, `test_a_pin_and_copy_pass_under_a_stuck_tab_strip`, `test_a_pin_in_a_pane_takes_one_seat_at_every_scroll`, `test_each_pin_case_seats_its_pins_by_their_targets_clear_of_what_they_hide`, `test_sticky_headers_stack_so_a_diff_in_a_tab_pins_under_the_strip`, `test_a_stuck_root_tab_strip_hides_what_passes_under_it`, `test_focus_in_a_stuck_header_leaves_the_page_where_it_is`) pass, serially under `taskpolicy -b`; `pnpm run test:runtime` (813) and `pnpm run check:browser` pass. Main's own change to `fixedInWindow` (a fixed box held by a transformed ancestor isn't fixed in the window) came in with the merge, so the header finder and pin seating read `inWindow`, its anchor-free form. Against main's runtime, 9 of the new test's first 10 subtests fail. `leaf-dev stills` on six header-adjacent catalogue states before that merge left 6 of 6 unchanged, so pages without such a header draw as before. A wider catalogue run timed out under load and wasn't retried. > _This was written by Claude Code on behalf of max-sixty_
A pin's seat read each sticky box where the current scroll drew it, so a pass made while a header inside the target stuck far down the page seated the pin where the header stands once the user scrolls back, and the next unrelated pass moved the pin with no input (#5165). `stuckShift` (geometry.js) reads how far sticking moves a box from its own place, from a view timeline whose scrollport end is inset by 100%: its start offset is a top-sticky box's own top, and its end offset a foot-sticky box's own foot, at every scroll, in Chromium and WebKit, and nothing on the page is written. A sticky box inside another in the same scroller takes off the outer box's offset. `coverIn` reads a sticky box's subtree where it is drawn and moves it to that place, except for a sticky box holding the target, which moves with the target. Firefox has no ViewTimeline and keeps the old reading, recorded in notes/browser-support.md. Behavior change: a pin by a sticky header takes the seat the header leaves at rest, at every scroll. `shifted` moves from box-motion.js to rect.js for both callers.
max-sixty
added a commit
that referenced
this pull request
Nov 5, 2026
…in layout failing in Firefox 159 (#5448) The user compared rules for what an empty comment box says, on a playground set against today's boxes, and chose this one. Every box now says its word, Reply or Comment, in one dim face, and keeps it with the caret in. - **The panel's key at rest stands with Comment**, after the agent's status, as Reply's does in a thread. It was the one key in a box without a word, and a reviewer reading the captures took it for the inbox's shortcut. `enters` in `composing/input.js` draws it in a part of its own, so the box's words never move between parts as focus comes and goes. - **The panel's Reply reads dim**, as a card's does. It had been inked since 27 October to stand apart from the agent's words. - **With the caret in, the panel says Comment or Reply**, as every other box keeps its word, in place of *Comment on the page* and *Reply in this thread*. A resolved thread still says *Reply to reopen*. Accessible names still say where the words go. While a notice offering a press stands in the row, such as a Resolve's Undo, that press stands alone, with no word or key beside it. It also carries a fix for a failure the user hit in Firefox 159.0. That release builds a `ViewTimeline` but throws NotSupportedError reading its `startOffset` or `endOffset`. Since #5211, `stuckShift` read one for every sticky box a margin pin's seat passed, so each margin layout pass whose pin passed a sticky box threw, and the page reported it to the user. It now asks for an offset once and, where that throws, reads a sticky box where it is drawn, as it already did in Firefox with no `ViewTimeline`. I reproduced the throw and checked the detection in the installed Firefox 159, headless; Playwright's Firefox 157 has no `ViewTimeline`, so no test can reach it. `test_c_enters_a_seated_reply_without_revealing_the_thread_heading` stood its thread wholly below the window, where `c` has written in the panel since #5428. It now keeps the thread in view with its reply below. #5428's CI passed without catching that. > _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.
A margin pin's seat no longer depends on how far the document was scrolled when the pass ran, when a sticky box stands in the room around its target. Closes #5165.
Cause.
coverInread each sticky box where the current scroll drew it. While the document was scrolled past a target, a sticky header inside it stuck far down, so the seat by the target's top read as clear and the pin took it. Once the user scrolled back the header's control stood on that seat, and the next unrelated pass moved the pin with no input. That brokemargin-layout.js's rule that remeasuring after a scroll writes the same insets. In lf-trace's playwright journey, the sticky.lf-trace-headinghit it: the failure in #5165.Fix.
stuckShiftreads how far sticking moves a box from its own place, and writes nothing to the page. A box's client rect andoffsetTopboth include the sticky offset, but a view timeline's range starts from the box's own place. Its scrollport end is inset by100%, so the start offset is a top-sticky box's own top and the end offset a foot-sticky box's own foot, at every scroll.coverInreads a sticky box's subtree where it is drawn and moves it to that place, except for a sticky box that holds the target, which moves with the target. A sticky box inside another in the same scroller takes off the outer box's offset, because the timeline leaves out both.shiftedmoves frombox-motion.jstorect.jsfor both callers.Behavior change. A pin by a sticky header takes the seat the header leaves at rest, at every scroll.
Firefox. It has no
ViewTimeline, so there a sticky box is still read where it is drawn. That gap is recorded innotes/browser-support.md("Sticky boxes' own place") with its recheck. Of the three options this PR first listed, unsticking during the pass wrote to the page, deriving the place from neighbouring flow re-implemented layout, and counting the whole travel as cover lost every seat in a sticky header's column (every lf-diff file and lf-trace widget).Verification.
test_a_pin_by_a_sticky_header_takes_one_seat_at_every_scroll(tests/browser/margin/test_scrollers.py) failed on main ({'dx': -4, 'dy': 0} != {'dx': -4, 'dy': 30}) and now passes in Chromium and WebKit. A nested case, where the control sticks inside the header, fails if the outer offset is counted twice, and now passes. Withfirefox_browseradded, the test still fails as described above.test_trace_replaces_captures_without_blank_pixels_or_layout_displacementwith--cpu-throttle 12failed in 2 of 3 runs on main here and passed 3 of 3 with the fix.-k "pin or seat or sticky or stuck or under": 68 passed.test_a_pin_by_a_card_full_of_controls_stands_on_it_clear_of_themerrored once under-n 3with a shift-watch miss on a page with no sticky box, then passed twice alone on both main and this branch. Runtime Node tests (812) and the browser type check pass.