Repository navigation
Leave a place the user scrolled away from out of the keys - #5192
Merged
Merged
Conversation
Focus stays in a margin card, or a thread seat, after the user scrolls it off screen with the wheel or reading keys. `r` then resolved that thread with nothing on screen showing it, and focus moved to its passage's mark, also off screen; only the notice said what had happened. Reproduced in Chromium and Firefox on review-a-plan: open the card by its marker, wheel 3200px down, press r. `r` and the copy key now act only on a thread `seenRect` says is in front of the user. Enter keeps reaching a thread scrolled away, since it lands in the reply box, which brings the card back (off-flow.js). The new test fails without the change: the card closes on the off-screen press. Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
Focus stays on a control after the user scrolls it off screen, and Leaf's keys acted there unseen: `r` resolved a thread card the user had scrolled away from, and a number key chose an option on a question nowhere on screen. Now, once a scroll has settled since focus arrived and none of the focused control is in front of the user (user-place.js, `focusScrolledAway`), the dispatcher resolves a key as though focus stood on the page: the control's element scopes and every page scope rooted at it leave. Typing keeps its field, Escape keeps every scope, and the control's native claims stay. This replaces the per-key check on `r` and the copy key in thread/landing.js, which is back to main's version. Behavior changes: - Enter on a thread card scrolled away does nothing; it used to land in the reply box and bring the card back. - `x` on a to-do follows the rule, since the to-do scope now declares `root: focused`. - A key pressed while a walk glides to its stop still acts on the stop: only a settled scroll counts, and the control is measured at the press, since a fixed card is placed again as a scroll settles. - Command hints repaint at a scroll's end while focus is scrolled away, so a question's digit chips come back with it. The dispatcher's import closure in .dependency-cruiser.mjs gains user-place.js and the geometry modules it reads; none is a painter or an application service. test_r_leaves_a_thread_the_user_scrolled_away_from now waits for the scroll to settle, the state the rule reads.
A native control scrolled away still takes the browser's own Enter and Space, and page commands still read where they start from focus, so the docs say so. Focus a change drops to the body no longer counts as an arrival, so a control handed back to after a drop stays scrolled away.
# Conflicts: # dist/kernel/leaf.js # dist/kernel/runtime/bundle-data.js
leaf-agent
approved these changes
Nov 3, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 4, 2026
#5192 made keys skip a focused place the user scrolled off screen. It measured the focused node, so wheeling the Threads list until its focused row left the list's view counted as leaving that row: ArrowDown then did nothing, where before it moved to the next row and brought it into view. The panel never left the screen. A focused node inside a scroller of Leaf's own chrome is now away only when that scroller is: scrolling a list doesn't leave the place it shows. Page places keep the rule as it was, including a thread card that rides the page off screen. `test_threads_arrows_move_on_from_a_row_scrolled_out_of_the_list` fails without the change. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Nov 5, 2026
…one rule (#5468) The last step of the cutover to one way to know what's on screen. The user's decision (2026-11-04): a key pressed while the focused place is off screen lets go of it first, and every key then acts from what the user sees. Accepted: after such a key, scrolling back doesn't bring the place's keys back until the user clicks or Tabs there, and Tab goes on from what they're reading. The rule is that focus is where the user is while they see it, else what is on screen. - **`focusPlace` (`user-place.js`) answers whether focus is where the user is.** It is while any of focus, or the box it stands at (`standsAt`: a thread's reply box, a shelf proxy's block), is in front of them, or while a running motion carries them to it: a glide, or a finite animation that moves a box holding it, as a board card's slide. A control in a stuck box counts unless something inside that box clips it away or it stands beside the window, and a row scrolled out of a chrome list counts while the list shows. It replaces `focusedInView` and `focusScrolledAway` with its settle flag. - **`keyboard/controller.js` lets go** (`letGo`, not Escape's release, so a card open beside the control stays open) before any other keydown listener of Leaf's reads the key. Escape, a key typed into a text field and a lone modifier keep the control; Tab types nothing, so it lets go of a field too. The key then stops at the document, so a listener on the control or a widget around it doesn't hear it, and Leaf's own command for it runs from there. A script's own listener on the document or window hears that one key only in capture; `module-input.md` says so. Chromium applies a radio's, slider's or select's own keys at the control the key was aimed at after focus moves, so those are withheld in every engine, and that one press scrolls nothing (`notes/browser-support.md`). - **`reading-place.js` `pageReadingBlock` is what the user reads otherwise:** the block across their column (`readingBlock` now takes the pointer's or focus's column, as `capturePlace` does), else, on a screen with no text block, what stands at the reading line, so a walk and a let-go start there rather than at the page's top. A key at focus the user can't see names no place (`declareFocusPlace`), so the pointer's column stays theirs for the let-go. - **Readers outside a key read the same rule:** `capturePlace`, `readerColumn` and three readers in `version.js` ask `focusPlace` (a stuck focus still names no reading place); `focusedPlace` in `composing/surface.js` does, for where `c` goes (#5428), with `user-place.js` still repainting at a scroll's end while focus is on a control; a let-go of something the user can't see leaves no walk origin (`current-target.js`); a tally's Next counts from the block read in its region. Deleted: the dispatcher's scope filter (#5192), the command hints' scrolled-away repaint, `focusScrolledAway`'s settle flag, `focusedInView`, and the dispatcher's dependency-cruiser closure entries they needed. Measured on a shot's view radios on `release-notes`, scrolled 1,100px past the shot, both engines: Space stayed on the radio and paged nothing on `main`, and now pages on. ArrowRight changed the view out of sight and moved the page 363px on `main`, and now changes nothing and moves nothing. Fixed where the let-go exposed them: - `reading-regions.js`: focus on the body named the page as the region the user reads since #5228, so `u` and `d` after a let-go, or after a click on a pane's words, scrolled the page instead of the region last acted in. - `off-flow.js`: Tab reaching a card the page carried away brings the card back, since Firefox can't reveal a control in a fixed box and the next key would let go. - `heading-links.js` reads the current location once the script ends, so a let-go's passing focus on a heading writes nothing. - `focus.js` `letGo` blurs what held focus after its landing, since inside a modal dialog the page is inert and takes no focus. Behavior changes, by test: - `test_r_leaves_a_thread_the_user_scrolled_away_from`: `r` away now takes focus out of the card, which stays open; back in view the open card is the conversation the page shows, so `r` resolves it. - `test_digits_leave_an_obligation_the_user_scrolled_away_from`: back in view the digits stay gone and `2` chooses nothing until `m` and Tab return to the ask. - `test_a_thread_walk_card_leaves_and_returns_with_its_anchor`: `c` after the `g` that let go of the card opens the page's field, not the card's reply; a click on the card's words and `c` reach the reply, and Tab from it still brings the card back. - `test_c_travels_to_an_item_its_own_scroller_has_taken_away`, renamed `test_c_leaves_an_item_its_own_scroller_has_taken_away`: `c` at a card a board carried away opens the page's field and leaves the board where it was scrolled; the sliver case focuses the card, which shows, rather than its cut-off link. - `test_a_crowded_outline_keeps_the_reading_position_when_it_fits_again`: Tab from a contents link scrolled out of its outline goes on from what the user reads, so the test scrolls back to the link first. - `test_vertical_landing_crosses_a_quarter_turn_without_changing_horizontal_reading`: `g z` with focus off screen aligns what the user reads, so the start case lands the target through `scrollIntoView` as the nearest case does. - `test_restore_selection_failed_datum_hydration_leaves_history_untouched`: the page's field wears `c` once the key let go of the line scrolled away. - `test_sample_file_editor_resize_keeps_classic_scrollbars_inside_its_document`: F2 pressed with the editor scrolled out of its sample lets go of the editor, and the sample's own listener now captures to hear that key. - `test_merge_film_inspection_has_touch_and_keyboard_routes`: the step pressing `i` on Next after scrolling it away is gone, since that key now lets go. - Setup only, focus now where the user sees it: the scroller-edge ring test (a taller window, focus by `focus()`), the seated-reply `c` test (a longer thread), the staged-controls test (summary clear of the panel) and the native-row test (an owner with a box). - Runtime: `unseen-focus.test.mjs` mounts the keyboard and checks the let-go, what hears its key, the arrow withheld at an unseen radio, Escape's step and a field's Enter; `user-place.test.mjs` checks `focusPlace` (a stuck heading now counts; a running slide carries, and an endless animation, a fade, a paused slide and a pseudo-element's slide don't); `dom.mjs` drops `inView`. - Added, both engines: `test_a_key_at_a_control_scrolled_away_acts_from_what_the_user_reads` (Enter, an arrow, End at a select, Space, and Tab from a link and a text field), `test_a_key_at_a_control_out_of_sight_in_a_fixed_box_lets_go_of_it` (a fixed box's scroller, beside a narrower window, inside a modal), `test_tab_at_a_control_scrolled_away_goes_on_in_the_column_the_pointer_is_in` (from a button and a field) and `test_tab_reaching_a_card_the_page_carried_away_brings_it_back`. - `test_motion_preference_changes_are_heard_without_reloading` failed about one run in five: a glide shares a frame the page already asked for (`rendering.js`), so with one pending when the test replaced `requestAnimationFrame` it recorded nothing. It now waits for the page to render first, and passed 14 of 14. Left as `main` has it: a same-origin Leaf frame scrolled entirely off the outer page still takes its keys, since a frame reads only its own viewport. A control in a stuck box is on screen, so a key acts there: after pressing a depth on a sticky `lf-dial` and reading on, Space stays with the radio, as focus on any sticky toolbar's button does in a browser. Two independent reviews ran; each case they confirmed against `main` that this change moved, or that departed from the decision, is fixed here with a test. Runtime +284 −157, net +127, against the prototype's +43: the fixes above and the header prose that records them. Tests +429 −94. > _This was written by Claude Code on behalf of max-sixty_
This was referenced Nov 5, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 5, 2026
`test_a_side_list_is_a_queue_beside_the_item_it_opens` failed in every scheduled run since 2026-11-03 because its last step pressed ArrowDown on a tab the test had scrolled out of sight. Since #5192, and as #5468 now states (`browser/runtime/keyboard/controller.js` header), a key at a control the user can't see lets go of it first and acts from what they see, so focus landed on `body` and Ticket c was never selected. The step's purpose is to show that a tab switch in a scrolling root set keeps the page's scroll position; it now scrolls the page to 12px short of the panel's top with both tabs in view, then walks to Ticket c and asserts `scrollTop` is unchanged. A switch that jumped to the page's top or to the panel would still fail it. #5468 updated the tests it moved, but this journey runs only nightly, so its pull request CI never reached it. No runtime behavior changes here: the walk from an off-screen tab is a gesture #5468 deliberately stopped honoring, and the repair keeps that decision. Verification: on `main` the test fails locally at line 276 (`aria-selected="false"` on Ticket c). A probe showed focus on Ticket b before the press and `letGo` (`focus.js`, called from the controller's capture listener) moving it to `body`. With this change the test passes in three local `--run-nightly` runs. Closes #5461 — automated triage Co-authored-by: leaf-agent <[email protected]>
This was referenced Nov 5, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 23, 2026
… momentum (#6892) The comment box beside a tall focused element now follows a scroll on every frame, a trackpad's momentum included. It waits at the window's top while the element scrolls past, goes in the frame focus leaves sight, and comes back in the frame the element does. Before, the resting box rode the element's top off the window, and on the way back it stayed hidden until the scroll stopped, for about 2.7 s with the element in view in Firefox. Nobody chose the wait. #1705 put the open box on CSS anchors, so no scroll solved it again. #5242 left the page plane that way with a TODO, and #5428 made the resting box ride the same way. After that, only the scroll-end repaint that #5192 added in `user-place.js` moved it. `focusPlace` has since read where glides land, so that repaint protected nothing. - `floating.js` solves a box again on each scroll around the element it watches. A solve beside the words writes nothing, and a box held in by the window's edge stands fixed. Each surface's `autoUpdate` takes `ancestorScroll: false`, so each scroll solves the box once. - `geometry.js` `whenChanges` reports each frame `focusPlace` flips, replacing the scroll-end repaint. `whenNone` now wraps it. - The open or resting box writes its width only up to the card's measure. A sideways scroll under it no longer rewrites `--lf-float-w` on every step. **Behavior changes to weigh.** Where `c` goes now updates during a scroll. The resting box goes as focus leaves sight, though its placement could keep it on screen a little longer. On a page where On Me lists anything, the panel's row shows Next On Me instead of `c`, so after the box goes nothing shows where `c` goes. `field-readings.js` records that choice. **Evidence** (Firefox, the `css-theme-structure` page, 1440×900): the resting box showed on exactly the frames where focus was in sight, 1013 of 1013; on the base, 360 frames owed a box and showed none. The open box held on 1030 of 1030 frames, keeping its typed words and focus. In Chromium, script time over a 160-frame smooth scroll was 11.5 ms against 11.3 ms on the parent commit. Max asked for this in a comment on a Leaf page, and a fresh-context agent reviewed it over three rounds. `test_the_box_beside_a_tall_target_waits_at_the_window_s_top_through_a_scroll` fails on the base in Chromium and Firefox, and `floating-placement.test.mjs` covers the scroll listeners. > _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.
Focus stays on a control after the user scrolls it off screen, and Leaf's keys acted there unseen:
rresolved a thread card the user had scrolled away from, with only the notice saying so, and aftermto a question and a scroll away,2chose an option on a question nowhere on screen.Now, once a scroll has settled since focus arrived and none of the focused control is in front of the user, the dispatcher resolves a key as though focus stood on the page. The control's element scopes and every page scope rooted at it (
root: focused) leave, so page keys such ast,mandcstill work. Typing keeps its field, since typing brings a scrolled-away box back, and Escape keeps every scope, so letting go lands where the user reads. The control's native claims stay: the browser still presses a focused native button on Enter or Space.browser/runtime/user-place.js:focusScrolledAwayowns the question. Only a settled scroll counts, since a walk focuses its stop before gliding there and a key pressed on the way is meant for the stop. The control is measured at the press, since a fixed thread card is placed again as a scroll settles.browser/runtime/keyboard/dispatch.js(stack): the rule, and its contract in the header andkeyboard/AGENTS.md.browser/runtime/queue-walk.js: the to-do scope declaresroot: focused, soxfollows the rule.browser/runtime/keyboard/command-hints.js: repaints at a scroll's end while focus is scrolled away, so a question's digit chips come back with it..dependency-cruiser.mjs: the dispatcher's import closure gainsuser-place.jsand the geometry modules it reads; none is a painter or an application service.notes/browser-support.md: Firefox never rings a thread card opened by a click, however the user then types, so nothing but the open card marks wherergoes.Behavior changes: Enter on a card scrolled away now does nothing, where it used to land in the reply box and bring the card back.
test_r_leaves_a_thread_the_user_scrolled_away_fromwaits for the scroll to settle, the state the rule reads.Left as they were: page commands still read where they start from focus, so
mafter a scroll walks from the scrolled-away place andcreplies in a scrolled-away card; whether a scrolled-away focus should stop counting as where the user is goes to the user as a separate decision. A live sample's keys still act when the containing page scrolls the sample away.Tests:
tests/runtime/unseen-focus.test.mjs,test_digits_leave_an_obligation_the_user_scrolled_away_from(choice and chips) andtest_r_leaves_a_thread_the_user_scrolled_away_fromfail with the rule disabled. Probed onreview-a-planin Chromium and Firefox.test_a_thread_resolved_while_its_reply_is_written_keeps_the_user_on_it[diff-clear]fails on main's runtime too; #5128 owns it.