Repository navigation
Find the page's own fixed or sticky header, and start Leaf's header slot below it - #5389
Merged
Merged
Conversation
…lot below it A header a page fixes at the window's top, or makes the sticky first thing in `body` or `main`, now stands over what Leaf draws and lands: a fragment link, `m`, `t` and Go to arrive below it; a block's Copy, a heading's link, a recording's bar and a margin pin scrolled under it pass under it rather than being drawn over it; Leaf's own sticky boxes (a page tab strip, `lf-dial`, a diff's file header) stick below it; and a pin on its own words keeps one seat on screen whatever the document's scroll when its margin pass ran. Leaf already had one model of what covers the top of a scroller, the sticky-header slot (`--lf-top`), which landings, what-the-user-sees readings and the frames chrome passes under all read. A header the page writes was missing from it, which is the one cause of the landing, the controls drawn over the header and Leaf's stickies sticking under it. `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 head, which it finds by place (the fixed or sticky box leading a holder of the Layout's box, from `body` in) or, for a fixed header nested elsewhere, by hit test at the window's top. How far down the window it reaches is `--lf-page-head`, which `base.css` adds to the slot for everything in `body` but the head, and `tokens.css` to the root's landing band. A header Leaf already counts (registered, or stacked into the slot by its holder, as a Workspace's phone header is) is left to the slot, so Leaf's headers stack below the page's. The pin on the header's words had a separate cause: pin seating read the room as though everything on the page scrolled with the pin, so a pass made while the page was scrolled read the words passing under the header as taken and let the pin take a seat above the window's top. A pin in a box that stands still in the window (fixed there, or the page's head) now reads only that box and seats within the window, and a pin on the page reads nothing standing still, the rule the margin already kept for a pane. `page-layout.md` no longer tells authors to give targets `scroll-margin-top` for such a header, `module-scroll-and-motion.md` describes the page's head, and `github-discoveries.html` drops its masthead from its cards' scroll margin. Not covered: a sticky header below a banner (it leads nothing), a second header the page stacks under its first, and #5211, whose sticky header sticks within one section. New test: `tests/browser/test_page_head.py`.
…ding room replace Leaf's Review of the first version found the page's header read wrongly in four ways: - A thin bar fixed over the header, such as a reading-progress bar once it spans the column, or a full-window overlay, replaced the header as the page's head, since the first fixed box hit was taken and only one head read: the slot fell from 96px to 4px and landings ended under the header. Every fixed box the hit test finds at the window's top, and every fixed or sticky box ahead of the page's content, is now read, and the deepest reach of those that qualify counts. - "First in `body` or `main`" was literal, so a skip link moved off screen or an empty anchor before a sticky header left it unfound. A head is now any fixed or sticky box ahead of the page's content: in `body` and any box around `main`, anything before `main`, and in `main`, its leading run up to the first box that takes room in its flow. A banner before a sticky nav in `body` no longer hides it either, and what stands above a sticky head keeps the root's slot (`data-lf-page-head="above"`), so the banner is under nothing. - A header that hides or slides in on scroll was read on the first frame after the scroll ended, mid-slide, and a transform resizes nothing. A reading now waits out the transitions and animations running on the heads and candidates, and reads again when they finish. - A page's own `scroll-margin-top` for its header added to Leaf's room, landing a target twice the header's height down (a fixed header's `[id]` margin moved a landing from 112 to 208). The heads now raise the slot only, and their room comes from the zero-specificity margin every box reads from it (surfaces.css), which a page's own `scroll-margin-top` replaces. The root's `scroll-padding-top` is Leaf's alone (`!important`), so a page's own, written for its header, adds nothing either: both idioms land a target once below the header. A head declares `--lf-head-inset: 0px`, as Leaf's own sticky headers do, so a control focused in it counts as shown rather than being scrolled toward on every Tab. `page-layout.md` now promises only that: a header fixed at the top, or sticky before `main` or at its start, needs no landing room; one further into `main` or inside a section does; a page's own margin replaces Leaf's; Leaf sets the root's padding. `github-discoveries` keeps its masthead in its cards' margin, as on main. Unchanged: a pin on a sticky head's words in Firefox still moves with the page once the head sticks (notes/browser-support.md, "A stuck sticky anchor in Firefox"), as on main. A search drawer fixed at the top under half the window's height counts as a head while open, since it does cover that band. Tests: `test_page_head.py`'s sticky page now puts a banner above it, a skip link and an empty anchor before it and a progress bar over it, and each page states its own room, as a target's margin or the root's padding. Against the first version's finder and slot rules, four of its subtests fail; without the `above` marking, the banner's does.
…ayout.md covers A header a framework renders at the end of `body`, fixed and floating a gap below the window's top, was not found: the hit test reads one point just below the top, and the place a head is found by looked only before `main`. A box fixed in the window that is a child of `body`, or of a box around `main`, after `main` now counts too, held to the same two conditions as every head: it spans the column's middle and reaches less than halfway down the window. `page-layout.md` now names those two conditions, which a tall header on a phone held sideways can miss, and says plainly that a `scroll-padding-top` on the page's root has no effect, so a header Leaf doesn't read takes targets' `scroll-margin-top`. Test: `test_page_head.py` appends such a header after `main` in place of the fixed page's own, and checks a block scrolled under it reads as covered at its foot; without the scan after `main`, that subtest fails.
…nWindow now answers landing walks
leaf-agent
approved these changes
Nov 4, 2026
This was referenced Nov 5, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
…#5417) Leaf's own landings now keep their full band (landing room below the head room, and clearance above the foot room and floating panel) while the user is in an editor inside a floating box. Chromium's native caret reveal still gets no padding there. This is the narrow #5182 repair @max-sixty chose on #4751: reply fields keep native text editing, and the rare overshoot when several keystrokes land in one frame stays accepted. **Cause.** #4833 sets the root's `scroll-padding` to 0 while a floating editor holds focus, so the native caret reveal stops moving the document under the editor. Leaf's landings read that same padding as their band (`geometry.js`, `landingInsets`), so any landing made during focus lost its room. Resume writing (`g i`) focuses the editor and lands its passage in the same task, which put the passage flush against the window's top (`y=-3.05` in #5182). **Change.** - The root states its band as `--lf-landing-top` / `--lf-landing-bottom` (`base.css`, registered `<length> | none`), and its `scroll-padding` copies them. - `landingInsets` reads a scroller's stated edges, falling back to `scroll-padding`. So the override zeroes only what the browser reads. - `motionBand` mirrors Chrome's scroll-anchoring region, so it keeps reading the computed padding. - The override moves from `annotation-chrome.css` into `base.css`, beside the padding it changes, as `!important`. Since #5389 made the root's `scroll-padding-top` `!important` inside the `lf-base` layer, the unlayered override had lost the top edge: it zeroed only the bottom, so #4833's top-edge protection was off. That is also why `[combined-selection]` started passing on main. This PR turns that protection back on. - The public `landingInsets` description in `module-scroll-and-motion.md` now says what it reads. **Verification.** - `test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame[combined-selection]`: with the override restored and the old `geometry.js`, it fails exactly as #5182 reported (`y=-3.046875`). With this change it passes, and the passage lands at `y≈9` under the 12px band, with the override active (`scroll-padding-top: 0px`, `--lf-landing-top: 12px`). - Also passing: all of `test_render_send_placement.py` and `test_public_api.py`, #4833's regressions (now subtests of `test_a_card_at_the_windows_foot_grows_back_to_how_it_stood`), #4751's `test_a_pointed_cards_reply_brings_the_pointed_row_back`, and 67 drafts/margin/threads/navigation tests selected by `-k "caret or reveal or resume or floating or foot or reply_row or follows"`. `pnpm run check` and pre-commit pass. - Two tests in that selection fail identically on main without this change, so they're inherited: `test_a_seat_send_at_the_window_foot_shows_the_thread_it_started[verdict]` and `test_a_thread_walk_starts_one_page_trip_and_reveals_its_nested_passage`. Nothing changes on screen while no floating editor holds focus. The band values are the same expressions as before. Fixes #5182. Closes #4751. Co-authored-by: leaf-agent <[email protected]>
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.
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:m,tor Go to lands its target under the header;lf-dial, a diff's file header) stick under it;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 (headerInsetingeometry.js) and the frames Leaf's marks and controls pass under (headerLevelsincss-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.jsnow owns the headers over the document: those packages register (registerRootHeader, moved frompage-layout.js) and the page's own. How far down the window the page's own headers reach is written as--lf-page-head, whichbase.cssadds to the slot for everything inbodybut those headers.A header counts when it spans the middle of the column, reaches less than halfway down the window, and is one of:
bodyor of a box aroundmain, beforemain, or a fixed one after it, as a framework renders a header at the end ofbody;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
bodyto 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-topreplaces.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.mdtold authors to give targetsscroll-margin-topfor a fixed site header. It now says which headers need no landing room, that a taller one or one further intomainstill needs it, that a page's ownscroll-margin-topreplaces Leaf's room, and that ascroll-padding-topon the page's root has no effect.module-scroll-and-motion.md, "Headers over the document", describes the page's headers.Choices
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 withhtml { scroll-padding-top }, such as a sticky toolbar after the title insidemain, now lands under it, at 22px against 82px on the base. The same page clearing it withscroll-margin-topstill lands clear. No page inexamples/ordocs/uses root padding. The maintainer picked this over reading the page's computed padding at runtime.Not fixed
notes/browser-support.md, "A stuck sticky anchor in Firefox"). The base does the same. A fixed header's pin holds in both engines.main, or inside a section, isn't read. Read a sticky box at its own place when seating a margin pin #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-dialfirst inmainon 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 undertaskpolicy -b;pnpm run test:runtime(813) andpnpm run check:browserpass. Main's own change tofixedInWindow(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 readinWindow, its anchor-free form. Against main's runtime, 9 of the new test's first 10 subtests fail.leaf-dev stillson 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.