Repository navigation
Close layers, hold keyed rows and rove Tab stops through focus.js - #2041
Conversation
A Tab between two controls inside one widget's shadow tree reaches the document as no focus event, so every reader listening for `focusin` on the document or on a light-DOM ancestor missed it. On pr-walkthrough, Tab from a diff's comment button to the next file's title left the shortcut bar naming the button's keys until a resize or the heartbeat repainted it. Each of those readers also decided for itself which moves were the runtime's own returns, or which were keyboard arrivals. focus.js now owns every focus event, and the readers read its publication: - `onStanding` calls `read(node, cause, left)`, adding the node the readers last heard the user stood on. A reader that moves focus itself starts a newer publication, and the older one goes to no later reader. Focus that leaves a node for another and comes back to it publishes again, as when the Threads list hands its focus on to the title the user stood on. - A `step` cause joins `return`, `press` and `move`: Tab or Shift+Tab, whether the browser moves the user or a Tab handler does in its place. `pressLed()` says whether the latest input was a press rather than a key. - `handBack` compares the placement count instead of a one-shot document `focusin`, so a move inside a shadow tree during its retry frame counts. - `handingBack` is exported for a box closing onto its thread; the unused `restoringFocus` and `placingChrome` exports are gone. Readers moved onto `onStanding`: the standing repaint (repaint.js), the keyboard controller's disarm, the response-options close, the covering surface's focus trap, reading continuity's edit record, the reading-region record, user-intent's place input, the More menu's opener, off-flow surfaces, the code-copy anchor refresh, the Threads list's landing and title choice, and the margin's reveal reset, labels, cluster arrival and `followStanding`. Behaviour that changed: - The Threads list skips landing on a `return` instead of reading `keepingPlace` and `restoringFocus()`, so a popover closing back into the list no longer re-lands its thread. A press held in the list still lands when it ends. `standOnThread` hands back through `handingBack`. - A panel card's title chooses its card on a `move` or `step`, replacing the `:not(:active)` guard; a press still chooses at its click, and a return chooses nothing. The list hands its own focus on to the open card's title under whatever cause gave the list focus, so `#passingFocus` is gone: a hold landing on the list while a failed candidate holds the user's card from it does not make the stand-in card their choice. keyboard/AGENTS.md says so. - A margin cluster unfolds on a `step` onto one of its controls, as its header says, rather than on any focus matching `:focus-visible`; focus put there by script no longer unfolds it. Three margin tests that put focus on a cluster's control by script now reach it by Tab or Shift+Tab. - The margin card and the standing unfold read a keyboard arrival from `pressLed()` instead of `:focus-visible`, so a press into a text field inside a commented target no longer opens its card. - Held news treats a `step` as an arrival, as it did a `move`. - An off-flow surface brings itself back for a move within it that is not a `return`. The lint rule `architecture/standing-listeners` refuses `focusin` and `focusout` anywhere in the layer and its packages (listeners, event-type lists, comparisons, Lit bindings) and `focus`/`blur` listeners on the document. Its config names each exception and why: focus.js, the interaction log's raw recorder, the reply row's entry, the margin cluster's and card reply row's `focusout`, lf-gloss and lf-toc, each asking about one element's own subtree in its own tree. It is a custom rule because flat config replaces `no-restricted-syntax` per config object rather than merging it. user-intent.js's place reading now registers its own `keydown`, which `test_the_register_is_the_only_way_a_key_enters_the_runtime` names as a fourth listener that answers no press. `test_tab_between_two_staged_controls_turns_the_shortcut_bar_over` covers the shadow-tree Tab. It fails on main and passes here. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…oring a pass later Follow-ups to the onStanding cutover, from its review and an A/B of its flakes. - A focused node hidden or removed under the user publishes `drop`, read as null and against the place readers last heard. On main a hide fired `focusout`, which repainted the shortcut bar; after the cutover the bar kept naming the keys of a control no longer there until the next input. Readers of where the user stands (held news, the More menu's opener, the margin's follow) let a drop pass, since its owner puts the user back, and that return is told against the dropped place. - Where the user stands is read again when a key's, a press's or a click's task ends (a tap focuses at its click), so a move between two nodes of a shadow tree no stage watches, as a component's own root makes, reaches the readers with the cause that input gave it, or `return` where it came out of a layer that closed (`test_a_tab_inside_a_shadow_tree_no_stage_watches_still_reaches_standing`, which timed out without it). - Each reader answers alone: one that throws is reported and the rest still hear, and a reader that moves focus ends the older reading by a counter, not a node compare. - The margin opens a cluster's options for the keyboard arriving on it again, a Tab or a route a key began, as `:focus-visible` did before the cutover; the cutover had narrowed it to Tab alone. A return opens nothing. The margin tests and the AGENTS.md wording go back to main's. - The lint also refuses `focus` or `blur` captured on any node. - user-place.js returns native anchoring at the rendering pass after a hold's release rather than at the release. Two thread renders back to back released one hold and took the next in the same script, writing `overflow-anchor` away and back, which the write watch reports. The cutover's timing made that 9 runs in 30 of `test_replaced_reply_compositions_keep_their_carets_and_leave_commands[send]` under load, against 0 in 30 on its base; with this change, 0 in 30 on both. The cost: a change made to that scroller with no hold of its own, and laid out between the release and that pass, gets no native anchoring. The window is the rest of the pass's round where the release falls inside a rendering pass, and up to a frame where it falls outside one; every thread-list render takes a hold. - keyboard/AGENTS.md says where a return choosing no title can leave focus on a closed title: a hold put back after the choice moved under it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Every focus the runtime and the packages place now goes through `focusDestination(node, cause)`, with the cause `move`, `step`, `return` or `press`, and every reader of where the user stands (`onStanding`) hears that cause. Before, about a hundred plain `focus()` calls published as the user's own move, and owners marked their own returns with flags only their own listeners read, so a return released held news, opened a margin cluster's options or chose a panel card the user never went to. - focus.js: `focusDestination` takes the cause; `returningFocus`, `placeChrome` and `handingBack`, and the `placing`/`handing` flags behind them, are gone. A placement inside another (a component's focus handler forwarding to its child, `forwardFocus`) keeps the outer cause; a placement made by a reader of standing names its own and counts as a placement. A closing layer's own hand-back, which the platform makes as a popover or dialog closes, is no newer word to a waiting hold, the rule `returningFocus` stated for one caller. The cause `press` is a route landing on a control to press it, as a go-to does, which opens nothing on arrival. - A stop is lent only to a drawn element that is no control of its own, and landing is read as focus on the element or inside a shadow tree it hosts (`standsIn`), so a text field whose editor took focus is landed on and not focused twice. - The survey's returns that published as moves now say `return`: the banner's refocus of its door and the control after a removal, the thread panel's invoker, the reaction list's own return, the auxiliary surfaces taking focus back, surface.js's return to Threads, and in the margin the cluster repaint, the card transfer and restoreStanding; so do carries across a re-render (RowFocus, the swipe deck, the board's grip, the thread card's hand-on, history and draft restores, a contribution activation's hand-on to the entry that replaced the pressed one, and the Asks view's restore after a revision). - Flags deleted: auxiliary-surfaces' `placingFocus`, the margin's `settlingOptionsFocus` and `suppressingOptionsArrival`, and the page map's `closeOwnsFocus` (every way out of the map now places focus itself as it closes the dialog; the `close` event places nothing). The margin's two cluster `focusout` listeners and its card's reply-row `focusout` are `onStanding` readers, so switching windows no longer folds a margin entry's options and the margin needs no exemption from `architecture/standing-listeners`. `fabFocusHandoff` stays: it is a delayed focus's token, which the next change takes up with the other delayed moves. - The auxiliary-surface controller's `focus()` is `landing()`, the node a covering surface lands the user on, so `.focus()` means only the element's. - The lint `architecture/placements` refuses a plain `focus()` outside focus.js and the text field (whose own `focus()` hands on to its editor), requires a cause at every `focusDestination` call, and refuses passing the function on as a value. `focusForNavigation`, a contribution's `focus(entryKey, cause)` and `focusThread` take the cause too. Behavior that changed: - A go-to or a generated route that lands on a margin control and presses it no longer opens the cluster's options and folds them again under the press; a travel landing on a margin control is a `move`, which opens a folded cluster as the keyboard arriving does. - `lf-diff`'s hunk walk and `lf-sample`'s return borrow a stop that leaves with the user instead of leaving `tabindex="-1"` on the rows and the sample host. - Fallbacks that called `document.body.focus()`, which did nothing, are gone. - Resolving a panel thread still lands the next thread in view and undoing it lands the reopened one as an arrival (`move`), so its news shows, as before. Tests: the focus browser suites (threads, read state, drafts, margin, anchors, navigation, controls, reactions, application boundary, widgets, chrome contracts and the interaction layers) fail exactly the 14 tests that fail on this branch's base and on main (67307c6) alone; `npm run test:runtime` and eslint pass. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # eslint.config.mjs # skills/leaf/assets/runtime/auxiliary-surfaces.js # skills/leaf/assets/runtime/composing/selection.js # skills/leaf/assets/runtime/focus.js # skills/leaf/assets/runtime/keyboard/controller.js # skills/leaf/assets/runtime/thread/landing.js # skills/leaf/assets/runtime/thread/thread-list-view.js # skills/leaf/packages/default/runtime/annotation-overlay/margin-projection.js
tests/runtime/focus.test.mjs asks focus.js, under happy-dom, that a move, a return and a step each reach onStanding as the cause the placement names, and that a placement naming none is refused. It fails before the change that gave focusDestination its cause, where every placement read as a move. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…one's The fold that replaced the cluster's focusout reads the node the user left, as the blur did: a node hidden under the user leaves the cluster and folds what it opened, and a node removed from under them folds nothing, since the render that removed it hands them on to its replacement, often a frame later. Tracking the cluster per reading instead folded on that removal and closed options a re-render was still handing back (test_reactions_keep_all_six_buttons_on_an_occupied_target and nine more). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
focus.js becomes the one reader of the user's inputs as well as of where they stand, so whether they have moved on since a hold began or a delayed move was scheduled has one owner, and so has the press in progress. - The input count moves from user-intent.js into focus.js (`inputCount`), which `retainUserIntent` reads; user-intent.js holds no listeners and no longer imports the keyboard. The count of placements stays beside it rather than merged into it: a hold compares placements, since the user typing in the box it holds is them working there, and delayed work compares inputs, since any key, press, wheel or touch since its gesture is a newer word. One count would void a hold on every keystroke, which tests/runtime/focus.test.mjs now states. - `focused()` moves from keyboard/scopes.js into focus.js with the label press it reads, and every importer cut over. The press on a label holds the user on the element they stood on until it lands, for every reader: holds and `holdStanding` read the held element, and no in-between node a press goes through (the body, or a containing thread that takes focus) reaches `onStanding` or counts as a placement, where before only the keyboard's `focused()` hid it. The press now lands at the label's click, whose default focuses the control, so it covers a tap, whose click follows its release; a release off the label, a native menu, a cancel, a key, the window losing focus and a runtime placement end it too. Standing is read once more a task later, so a label whose control takes no focus leaves the user nowhere as their own move rather than with no reading at all. scopes.js keeps the focus-ring classes it paints on the held element, as an `onLabelPress` reader. - One reading of the press in progress (`pressing`, `onPress`), from the primary pointer's `pointerdown` to its end, replaces the panel list's `pressedPointer`, the reading regions' `pressing`, the margin card's press-away pair and the thread standing's own press listeners. A release completes a press; a cancel, a native menu swallowing the release and the window losing focus end it uncompleted, which the panel list and the margin card had not heard before. The place input (`recentPlaceInput`) moves into focus.js too, and `MODIFIER_KEYS` into control-selectors.js, which focus.js may import. - The delayed focus moves that never asked now ask: the reaction removal's focus on the next render (inputs only, since the render may carry focus to the replacement control), the composer's response options after the bar places, the swipe deck's Return after the log answers, and the margin card's deferred focus. Each gives way to any input the user made meanwhile. A hold that carries the user to the node a render put in place of theirs records the handoff (`carriedFrom`), so delayed work begun on the old node still follows them there while they have done nothing since, as it did a container's handoff (`passOn`). No lint rule this time: the copies this removes read standing or the press through hooks that now live only in focus.js, and a syntactic rule against input listeners would refuse the gesture owners (drawing, held words, aim) that rightly keep their own. Behavior that changed: - During a press on a label, a hold restores the element the user stood on rather than the in-between node, and no reader hears the in-between node. - A press whose release a native menu swallowed, or that the window lost, no longer leaves the panel list believing a press is still held. - A delayed focus no longer pulls the user back after they pressed, typed or scrolled elsewhere. Tests: tests/runtime/focus.test.mjs states the rules (a hold survives typing and gives way to a placement; delayed work gives way to any input; a label press through the body, through a focusable container, and onto a control that takes no focus); they fail on the tree before this change. The focus browser suites and the render gate fail only the tests that fail on main (55ba7de), and once test_focus_paint_releases_every_text_box_crossed_before_a_frame, which an interleaved A/B under load passes 30 of 30 on both arms. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/assets/runtime/composing/surface.js
The last phase of the focus overhaul gives layers and widgets the primitives they were
each writing for themselves, and exports them to widgets through widget-api.js.
- `closeLayer(close, land)` closes a layer the user may stand in and hands them on as
one act. Whatever focus does while it closes (the platform's own hand-back as a
dialog or popover closes, an owner's hand-back to the control that reopens it, the
drop to the body as a focused node hides) reaches no reader of where the user stands
and counts as no placement; the landing then runs, and readers hear one reading of
where the user ends up. The thread panel's Escape placed focus twice (back to the
toggle, then onto the page), and the page map, command reference, versions menu, a
More menu entry, the margin card's dismissal and activation, and a reaction sent
from the bar each placed it two or three times; each now closes through
`closeLayer`.
- The auxiliary surfaces (Threads and the drawers) own their landing: each registers
its `opener`, the control that opens it again, and its own hide moves no focus.
Closing hands a user who stood in it back to the opener, or lets them go where it is
gone, or wherever the closer's `land` puts them, as the Escape step's `letGo` does.
The panel's and drawers' `handBack` from inside their hide, and the `returnFocus`
option only the drawers' Escape set to keep that hand-back from running before it let
go, are gone.
- `holdFocus(scope, { key })` holds the user's place in a keyed list: its restore
tries the item now carrying the same key, then the nearest that survived after it,
then before it, then the caller's stand-ins, landing in each on the control like the
one the user stood on. `RowFocus` (retained-face.js), a second
implementation of the same rule, is deleted; the Queue and Leaves lists hold keyed.
lf-targeting's target and change lists hold keyed across their rebuilds, so removing
a target or change no longer drops the user to the body: they land on the next
row's Remove, or on Select element when none is left.
- `rove(items, stop)` sets a group's one Tab stop, replacing the margin's, lf-tabs'
and the swipe deck's hand-written loops.
- Widgets reach `closeLayer`, `focused`, `handBack`, `holdFocus`, `rove`, `whenLeft`
and `standingIn(scope)` (whether the user stands in a scope, across shadow trees)
through widget-api.js.
Left for later, named so the next change can take them: the layers outside the
auxiliary surfaces (page map, command reference, media viewer, target picker, the
composer and its reactions) still record their own opener and land through
`closeLayer` from their own closers, and the composer's and margin options'
`returnFocus` flags remain; the other keyed matchers
(lf-diff's counterpart line, lf-command's projection focus, lf-visual-review's
disposition, the margin's re-presented cluster, and the Asks, carry and draft restores
across a revision) still find their replacement node themselves; the command
reference's roving walk and the media viewer's hand-back from its `close` event are
untouched; and no lint rule refuses a new layer return outside `closeLayer`.
Behavior that changed:
- Removing a target or change in lf-targeting keeps focus in the list.
- Closing the thread panel, a drawer, the page map or the command reference by Escape
tells the shortcut bar and every other reader of standing once, where the user lands,
instead of passing through the control that reopens the layer.
The command reference closes through `closeLayer` and hands the user back after the
repaint that draws the shortcut bar's More again, as before.
Tests: tests/runtime/focus.test.mjs adds a keyed hold, a layer close heard once, and a
roving group; a targeting probe (`leaf-dev probe developer/targeting-gallery --base`)
lands on BODY at base and on the next row's Remove, then Select element, here. The
focus browser suites, render gate and initial delivery fail only the tests that fail
on main (9bf9287); two runs of
test_a_turn_arriving_leaves_a_user_who_scrolled_away_from_their_box_reading failed
under load and pass 8 of 8 on both arms of an interleaved A/B.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A hold reads placements, since the user typing where it holds is them working there; delayed work reads inputs, since any input since its gesture is a newer word. The header now says so beside the counts, with the merge into one count it rejected. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The register test grepped single lines for addEventListener("keydown", so a call
wrapped across lines, or one registered for several event types in a loop, escaped it:
it counted 3 where 10 are registered. tests/keydown_listeners.mjs now reads them from
each module's acorn parse, and the test pins the count per file and names each: the
dispatcher, the aim latch, the prepaint hold, focus.js's three readings of a key
(an input, the end of a label press, a Tab's step), the interaction log, a covering
surface's Tab loop, and the code block's two (its copy control handing Tab back to the
source, and the block's Enter moving to that control, which no register row declares).
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ts primitives
Finishes phase 4: the layers, keyed matchers and roving loops that still kept their
own copies now use focus.js's, and a lint refuses a new layer return beside them.
- `openLayer(layer, opener)` and `openerOf(layer)` record where a layer was opened
from, the control the user stood on by default, and nowhere for the body. They
replace the page map's `from`, the command reference's origin, the media viewer's
origin, the target picker's opener, the drawers' `openedBy`, the composer's
`fabOrigin` and react mode's `reactFrom`; widgets reach them through widget-api.js.
- Closing goes through `closeLayer` everywhere it hands the user back:
- The composer's `showFab(null)` moves no focus, and its `returnFocus` option is
gone: `putAwayFab()` hands the user back to where the bar's gesture stood them, and
`letGoOfFab()` lets them go onto the page; each reads its landing before the bar
goes.
- React mode closes in one act (`closeReact`): the palette's own hand-back reaches no
reader, and the user goes back once through `handBack`, to the first of the bar's
field, the control the press stood them on and the list's trigger that stands as
the choices go, which replaces the palette's hand-rolled return now and a frame
later.
- The other responses, the target picker, the media viewer and the command reference
(which hands back after its repaint) close through it. A target picker opened from
the page now lets go as it closes, as before.
- The margin's fold takes a `land` instead of `returnFocus`, its card closes through
`closeLayer` with `landOnEntry` for its own Close and Escape and a let-go
otherwise, and the card transfer's flag is a `carry`: the user standing on the
entry the card hung from moves with it, which is no return.
- A close inside another lands nobody and tells nobody; the outer close's landing
takes the user on, or the first inner one where it names none, and nothing an
inner close deferred outlives the outer one, a throw included.
- The margin card's Escape lands the user wherever they stood, the page their press
displaced included, as before.
- Keyed holds: lf-diff marks each line's text and its gutter Comment with the line's
key (`data-lf-line`), so a re-render lands on the same line's like node, then the
nearest surviving line, then the file's summary; its counterpart lookup is deleted.
lf-visual-review keys dispositions on `data-disposition` when the user stands on one.
The margin's re-presented cluster keys entries on their owner and key
(`data-lf-margin-entry-identity`), and the nearest surviving entry now comes before the
primary. The keyed hold reads rows in the shadow tree they stand in, prefers drawn
rows, counts a key that marks several nodes once, and lands on the node like the one
the user stood on.
- Not keyed holds, by design: lf-command's `projectionFocus` hands focus from one view
root to the root that replaces it, possibly reseated elsewhere, matching a link,
view, task control or title by role, so no one scope holds both; and the Asks,
carry, draft and margin standing restores read in one document and restore in the
one that replaces it, which no live hold spans. The More menu's `opener` holds a
caret and a selection, not an element, so it stays a hold.
- The command reference's results rove through `rove()`.
- Landing reads the root's active element (the body still by `:focus`), which holds
inside a shadow root where `:focus` may not match. The climbs across shadow trees
read a host only off a shadow root: a document names `<form name="host">` as
`document.host`, and a climb reading `.host` off the document looped for good
(test_a_page_element_named_host_leaves_the_keyboard_climb_at_the_document, which
hung a suite run until its 30-minute timeout).
- The lint `architecture/layer-returns` refuses `handBack(...)` outside a
`closeLayer` call's arguments or a landing named `land…`, aliased, namespaced or
passed on as a value included. `letGo` is also a route (`g p`), so it is not
refused. A `focusDestination(…, "return")` after hiding a layer by hand is not
caught.
- module-authoring.md documents `openLayer` and Escape as a command row, and a new
eval case, evals/widget-list-keeps-focus, asks for a keyed list and a popup that
hands back.
Behavior that changed:
- A diff line or margin entry a re-render removed now leaves the user on the nearest
surviving one rather than the file's summary or the cluster's primary.
- React mode's close and the composer's put-away reach readers once.
Tests: tests/runtime/focus.test.mjs adds a keyed hold through a shadow tree landing on
the like control, an opener handed back with a nested close heard once, and an inner
landing running under a close that names none. The focus browser suites, render gate
and the command, visual-review and initial-delivery suites fail only tests that fail
on main. Evals
(claude-code and codex, candidate against the merge base): widget-list-keeps-focus
passes 5 of 6 candidate runs (one Codex run kept the opener in its own variable,
which the reference now answers) and 0 of 6 base runs; view-reveal-arrival,
widget-controller-lifetime, widget-owned-context-keys and
shared-contribution-actions pass 8 of 8 on the candidate and 7 of 8 on the base.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ser's seat too The composer's seat climb read `.host` off whatever root it reached, so past the document it took `document.host`, a `<form name="host">`, and walked back into the page for good wherever the seat had no width; it now climbs with shadow.js's `upFrom`. focus.js keeps its own copy of the same check, since a runtime primitive imports no other owner, and asks the node type as `shadowHost` does, so a frame's runtime climbs its parent's nodes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/assets/runtime/keyboard/page.js # skills/leaf/assets/runtime/thread/held-news.js # skills/leaf/assets/runtime/thread/narrowing-view.js
…ding as one
`architecture/layer-returns` let `handBack` stand anywhere in a `closeLayer` call's
arguments and in any function whose name began `land`, so a hand-back in the close
argument passed, as did any function someone happened to name `land…`. It now admits
one only in the `land` argument, or in a function wrapped in focus.js's new
`layerLanding(land)`, which a closer builds away from the call when several closes
share it (the margin's `landOnEntry` and `landOnToggle`, the composer's
`landingFromBar`). A layerLanding throws if it runs at any other time, which covers
the flow lint cannot follow, as a landing handed through `setOptionsOpen({land})`.
The rule also refuses a `focusDestination(…, "return")` outside a landing where a
statement before it in its function hides something (a `hide`, `hidePopover` or
`close` call, `hidden = true`, or a style taking the box out of view). That found one:
withholding the composer bar hid it and returned the user to Threads beside the
hide. It is now a `closeLayer` with that return as its landing.
Behavior: unchanged. The withheld bar's return reached readers once before as well,
since the hide moves focus only at the next style pass; the close now says so.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
closeReact filtered its candidates (the bar's field, the press's opener, the list's trigger) to those visible before the close ran, so one the close itself shows, as putting the bar back shows its field, was never a way back, and a candidate the close hid was handed back to and missed. Which candidates are owed is still read before the close, since it reads where the press came from; which of them stand is read in the landing. Behavior: the user lands on the first candidate standing once the choices are away. tests/runtime/reactions.test.mjs closes a list whose close hides the opener and shows the trigger; it landed on the body before and lands on the trigger now. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…the rule `architecture/layer-returns` admitted a `handBack` anywhere lexically inside a close's `land` or a `layerLanding`, so one in a timer, after an await, or in a close a landing made passed, though each runs beside the close. It now admits one only where the function it runs in is itself the landing, through the `&&` or `?:` that picks it, and synchronous. A `handBack`, `focusDestination` or `letGo` written in a close's `close` is refused outright, since the close hides and places nothing; an aliased `focusDestination` import is tracked as `handBack`'s is. `closeLayer` clears the landing flag while its `close` runs, so a `layerLanding` called from a close made inside a landing throws as it would anywhere else. closeReact's landing now hands back to whichever candidates are drawn after the close, or lets go where none is, as `handBack` does for a closer that names no place. It had placed nothing in that case, where the reading taken before the close had handed back and let go a frame later. "Drawn" is focus.js's `drawn`, which counts `visibility: hidden` as hidden, in `handBack` too: a withheld composer bar's field no longer counts as standing. tests/runtime/layer-returns-rule.test.mjs runs the rule's visitors over acorn's tree, since eslint lives only in pre-commit's environment; against 2de5e0d's rule its refusals fail. Behavior: where no candidate stands after the reaction choices close, the user is let go on the page at once, overriding any landing a close inside it deferred, as any named landing does; withholding the bar inside another close defers its return to Threads to that close's landing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's native auxiliary dialog (#2006) and the code it moved conflicted with this phase's placements. Main's version stands, carried onto focusDestination: the covering surface's `focus` is `landing`, its Tab wrap places with `step` and its entry with `move`, and the swipe deck's and the playground's restores say `return`. Main wrapped its native layer transitions (`transitionNativeAncestor`, the auxiliary envelope's re-seat) in `returningFocus`, which this phase deletes. Those are a dialog's own showModal and close, whose focus moves no focusDestination can make, so focus.js gains `nativeLayerSteps(steps)`: what they do with focus is the layer's return, and no newer word to the hold waiting across them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's code, through phase 2's merge, conflicted with this phase's moves on import lines and two listeners. `focused` comes from focus.js beside main's new imports (target-picker, reading-place, panel-elements, surface, page.js, held-news). reading-regions keeps main's click reader of reading input and drops its own press flag for focus.js's `pressing`. The swipe deck takes main's synchronous Return, which focuses the next card in the press's own turn, so it has no delayed move to ask `retainUserIntent` about. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's native auxiliary dialog and its anchor-derived composer return, through the two lower phases, conflicted with this phase's layers. - The auxiliary surfaces keep main's one native dialog and add this phase's `opener`: closing the previous surface goes through `closeLayer`, handing a user who stood in it back to the opener or wherever the closer's `land` puts them, and its `hide` moves no focus. The drawers record their door with `openLayer` and keep main's keyboard-activation `focus`. - The composer takes main's design, which keeps no pre-command focus: the bar's subject, from `returnPlaces(anchor)`, is where `putAwayFab` hands the user back and what `letGoOfFab` lets them go from, so `openLayer(fabBar)` and its `origin` option are gone. The reaction sent from the bar hands back to those places. - `nativeLayerSteps`, which phase 2's merge added for main's dialog re-seat, is `closeLayer` with no landing here: the envelope's posture change and `transitionNativeAncestor` close through it, and the hold put across them puts the user back. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's in-place image inspector (#2037) conflicted in media.js, where the viewer's Close takes focus as it opens: it does so through focusDestination as a move. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's in-place image inspector (#2037) conflicted with this phase's viewer layer: the viewer records its opener with openLayer as it opens, and closing destroys the inspector and empties its stage inside closeLayer, handing the user back to that opener. The drawers keep main's label beside this phase's record of no openedBy. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's newer code conflicted with this phase's placements and is carried onto focusDestination: - auxiliary-surfaces: main's `edge` joins the registration's requirements, and its covering entry, which main wrapped in `returningFocus`, lands the surface's `landing` as a `return`. - The target picker's page search, after main reserves its count, takes focus as a `move`; the floating response's withheld bar returns to Threads, now also where a covering surface took the room, as a `return`. - lf-draft's rewritten close returns the user to the draft or its Edit control as a `return`; thread/panel.js keeps main's `rowWalk` beside its focus import. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's newer code conflicted where this phase moved `focused` and the place input into focus.js. thread/panel.js and reading-place.js take `focused` from focus.js beside main's imports. Main taught user-intent.js's place input that a repeated click can choose the focused destination without moving focus; the place input is focus.js's here, so focus.js reads that click itself, and user-intent.js stays free of listeners. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's one side panel for Threads and Questions (#2051) conflicted with this phase's surface closes. Selecting a surface on the same edge swaps it where it stands: the previous surface's `hide({ swap })` runs inside `closeLayer`, which hands a user who stood in it to its opener or the closer's `land`, and the drawers' hide takes only `swap`. The withheld composer bar keeps main's covered-panel case inside its `closeLayer`, and queue-panel's header names the keyed hold. The auxiliary dialog's re-seat now lands through its `closeLayer`: the hold put across it puts the user back, or a user entering a covering surface from outside lands on its landing, as the close's `seatLanding`. The lint refused that entry as a return after the re-seat's popover hides. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main moved lf-diff's line coordinate into diff-coordinates.js (`diffDatumKey`), and this phase's keyed hold marks each line with it, so `data-lf-line` carries the datum key and the hand-written `lineKey` is gone; main's counterpart lookup stays deleted. media.js keeps main's `offered` beside this phase's layer imports. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's recording review (#2100) focuses a timeline marker and the image canvas on pointerdown, where a plain focus() would publish as a move; each now places with `press`, the cause of a press landing on the control it pressed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's change releasing hidden focus before a delayed return (#2078) counted the user's inputs in focus.js a second time (`inputEpoch`); `handBack`'s pending return now reads this phase's `inputCount`, so a key, press, wheel, touch, text input or window blur cancels it, and the second counter is gone. Main's `onUserInput`, which observed the same inputs from user-intent.js, joins them in focus.js, and widget-api exports it from there, so user-intent.js still holds no listeners. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Phase 2 landed as 00691d6. Every conflict is that squash meeting the phase 2 commits this branch already holds, so each conflicted file is re-merged against phase 2's tip (27da30f) as the base, leaving only main's own seven later changes to meet this phase's; none conflicts. The swipe deck lost a duplicate focusDestination import the old base produced. The branch's diff against main is now exactly phase 3's. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
controller.js takes main's `quickShortcuts` from bindings.js beside this phase's MODIFIER_KEYS from control-selectors.js and `focused` from focus.js. Main's quick-shortcuts switch (#2121) put the user back on the More menu's door with a plain focus(), which phase 2's lint refuses on main as well; it is a `return` through focusDestination here. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The command reference records its opener with openLayer beside main's `availableCommandRoutes({ commands: true })`. Main's keyboard-shortcuts entry in the More menu closes the menu through closeLayer, landing the user on its door, which the complete reference then returns them to.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main fixed the keyboard-shortcuts entry's door focus the same way this branch had (#2122), so shortcut-bar.js is main's. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/assets/runtime/keyboard/shortcut-bar.js
focus.js becomes the one reader of the user's inputs as well as of where they stand, so whether they have moved on since a hold began or a delayed move was scheduled has one owner, and so has the press in progress. Phase 3 of the focus overhaul, after phase 2 (#2036); phase 4 (#2041) stacks on it. **Two counts, decided.** A hold and delayed work read different counts, and they stay apart. A hold compares placements, since the user typing in the box it holds is them working there; delayed work compares inputs, since any key, press, wheel or touch since its gesture is a newer word. One count would void every hold on each keystroke. Rejected: merging them into one "since" count. tests/runtime/focus.test.mjs states both rules, and phase 4 writes the decision into focus.js's header. - The input count moves from user-intent.js into focus.js (`inputCount`), which `retainUserIntent` and `handBack`'s pending return read, the latter in place of the second counter #2078 added; `onUserInput`, which observes those inputs at their edge, moves with it. user-intent.js holds no listeners and no longer imports the keyboard. - `focused()` moves from keyboard/scopes.js into focus.js with the label press it reads, and every importer cut over. The press on a label holds the user on the element they stood on until it lands, for every reader: holds and `holdStanding` read the held element, and no in-between node a press goes through (the body, or a containing thread that takes focus) reaches `onStanding` or counts as a placement, where before only the keyboard's `focused()` hid it. The press lands at the label's click, so it covers a tap; a release off the label, a native menu, a cancel, a key, the window losing focus and a runtime placement end it too. Standing is read once more a task later, so a label whose control takes no focus leaves the user nowhere as their own move. scopes.js keeps the focus-ring classes it paints on the held element, as an `onLabelPress` reader. - One reading of the press in progress (`pressing`, `onPress`), from the primary pointer's `pointerdown` to its end, replaces the panel list's `pressedPointer`, the reading regions' `pressing`, the margin card's press-away pair and the thread standing's own press listeners. A release completes a press; a cancel, a native menu swallowing the release and the window losing focus end it uncompleted, which the panel list and the margin card had not heard before. The place input (`recentPlaceInput`) moves into focus.js too, with main's rule that a repeated click can choose the focused destination without moving focus, and `MODIFIER_KEYS` into control-selectors.js. - The delayed focus moves that never asked now ask: the reaction removal's focus on the next render, the composer's response options after the bar places, and the margin card's deferred focus. Each gives way to any input the user made meanwhile. A hold that carries the user to the node a render put in place of theirs records the handoff (`carriedFrom`), so delayed work begun on the old node still follows them there while they have done nothing since. No lint rule: the copies this removes read standing or the press through hooks that now live only in focus.js, and a syntactic rule against input listeners would refuse the gesture owners (drawing, held words, aim) that rightly keep their own. Behavior that changed: - During a press on a label, a hold restores the element the user stood on rather than the in-between node, and no reader hears the in-between node. - A press whose release a native menu swallowed, or that the window lost, no longer leaves the panel list believing a press is still held. - A delayed focus no longer pulls the user back after they pressed, typed or scrolled elsewhere. Tests: tests/runtime/focus.test.mjs states the rules (a hold survives typing and gives way to a placement; delayed work gives way to any input; a label press through the body, through a focusable container, and onto a control that takes no focus); they fail on the tree before this change. `npm run test:runtime` (262) and eslint pass. The focus browser suites (chrome contracts, navigation, controls, threads, widgets, margin, anchors, drafts, reactions, aim, read state, interaction layer, send placement) fail 11 and pass 2169, against 6 and 2174 on main (81e0e10), all 6 shared. Of the rest, the reference's filtering at its narrowest viewport, the Tab-stop reading and `test_the_reading_page_keys_follow_the_user_into_the_panel` fail on main too in interleaved A/Bs, and four navigation tests that timed out under the suite's load pass 3 of 3 on both arms. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Phase 3 landed as 1e9fad2. Each conflict is that squash meeting the phase 3 commits this branch holds, so each conflicted file is re-merged against phase 3's tip (8e85f82) as the base, leaving main's own later changes (#2116, #2039) to meet this phase's; none conflicts. The branch's diff against main is now exactly phase 4's. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Max approved audit finding #9: cancelling Page Map with Escape should return to its invoking control or prior reading position, while activating a heading or thread link should still navigate to that destination. The phase-4 cancel handler currently calls closeLayer(leavePageMap, letGo), while Close returns through handBack. Could you share one cancellation/Close routine using openerOf(dialog) and handBack within closeLayer, and update the module and keyboard cancellation contracts accordingly? Please verify both routes from a scrolled page and nested reading region, including an absent opener; keep selected-link navigation separate.
|
Capture the actual focused opener when Page Map opens, and share one close landing for Escape and Close. Without an opener, handBack retains the reading position. Keep action activation on its destination path. Browser checks cover both cancellation routes in document and nested scrollers, plus a scrolled page without an opener.
|
Implemented on this PR in 9a482b95. Escape and Close now share one cancellation routine that calls The six browser cases covering both routes from a scrolled page and a nested reading region, including an absent opener, pass. The existing selected-entry navigation test passes, and the PR checks on this head settled green. |
The last phase of the focus overhaul gives layers and widgets the primitives they were each writing for themselves: closing a layer and landing the user as one act, recording where a layer opened from, holding a place in a keyed list, and a group's one Tab stop. Widgets reach them through widget-api.js, and a lint refuses a layer return made beside them.
Phase 4, the last of the focus overhaul, after phase 2 (#2036) and phase 3 (#2038).
closeLayer(close, land)closes a layer the user may stand in and hands them on as one act. Whatever focus does whilecloseruns (the platform's own hand-back as a dialog or popover closes, the drop to the body as a focused node hides) reaches no reader of where the user stands and counts as no placement;landthen puts the user where the close takes them, and readers hear one reading. A close inside another lands nobody and tells nobody: the outer close's landing takes the user on, or the first inner one where it names none, and nothing an inner close deferred outlives the outer one, a throw included. A native layer closed and shown again in one act, as the auxiliary dialog's posture change andtransitionNativeAncestorre-seat it, closes through it too, replacing phase 2'snativeLayerSteps: the re-seat's landing puts the user back through the hold put across it, or lands a user entering a covering surface from outside on its landing.openLayer(layer, opener)andopenerOf(layer)record where a layer was opened from, the control the user stood on by default and nowhere for the body. They replace the page map'sfrom, the command reference's origin, the media viewer's origin, the target picker's opener, the drawers'openedByand react mode'sreactFrom. The auxiliary surfaces (Threads, the drawers) register anopener, theirhidemoves no focus, and closing hands a user who stood in one back to its opener, lets them go where it is gone, or follows the closer'sland, as the Escape step'sletGodoes; two surfaces on one edge (Threads and Questions) swap inside the same close.closeLayer: the thread panel and drawers, the page map, the command reference (after the repaint that draws the shortcut bar's More again), the versions menu and a More menu entry, the media viewer, the target picker (which lets go when opened from nowhere), the margin card (landOnEntryfor its own Close and Escape, a let-go otherwise), the margin's fold (landreplacesreturnFocus), react mode (closeReact), and the composer. The composer keeps main's anchor-derived return:putAwayFab()hands the user back to the bar's subject,letGoOfFab()lets them go onto the page, andshowFab(null)moves no focus, so itsreturnFocusoption is gone. React mode reads which way back is owed before the close and which candidates are drawn after it, so one the close shows is a way back and one it hides is not.layerLanding(land)marks a landing several closes share and built away from the call (the margin'slandOnEntryandlandOnToggle, the composer'slandingFromBar); it throws if it runs at any time other than as a close's landing.holdFocus(scope, { key })holds the user's place in a keyed list: its restore tries the item now carrying the same key, then the nearest surviving one after it, then before it, then the caller's stand-ins, landing on the control like the one the user stood on. It reads rows in the shadow tree they stand in, prefers drawn rows, and counts a key that marks several nodes once.RowFocus(retained-face.js) is deleted; the Queue and Leaves lists, lf-targeting's target and change lists, lf-diff's lines (data-lf-line, whose counterpart lookup is deleted), lf-visual-review's dispositions and the margin's re-presented cluster (data-lf-margin-entry-identity, owner and key) hold keyed. Not keyed, by design: lf-command'sprojectionFocushands focus between view roots, and the Asks, carry, draft and margin standing restores span a document replacement that no live hold spans.rove(items, stop)sets a group's one Tab stop, replacing the margin's, lf-tabs', the swipe deck's and the command reference results' loops.standingIn(scope)says whether the user stands in a scope across shadow trees.architecture/layer-returnsadmitshandBack(...)only in a landing's own synchronous body: the function passed as a close'sland, through the&&or?:that picks it, or onelayerLandingwraps. AhandBack,focusDestinationorletGowritten in a close'scloseis refused, as is afocusDestination(…, "return")outside a landing after a statement that hides something by the platform's means (hide,hidePopover,close,hidden = true, a style taking the box out of view), and aliased imports of both are tracked. That last found one: withholding the composer bar now closes throughcloseLayer. tests/runtime/layer-returns-rule.test.mjs runs the rule over acorn's tree, since eslint lives in pre-commit's environment. The keydown-listener test counts listeners from the parsed source (tests/keydown_listeners.mjs) rather than a grep.<form name="host">asdocument.host, and a climb reading.hostoff the document looped for good.openLayer/openerOfand Escape as a command row; evals/widget-list-keeps-focus asks for a keyed list and a popup that hands back.Behavior that changed:
Tests: tests/runtime/focus.test.mjs adds a keyed hold through a shadow tree, a layer close heard once, an opener handed back with a nested close, an inner landing under a close that names none, a roving group, a
layerLandingrefused outside a close, and a keyed hold that reads the rows once however many held keys have gone; tests/runtime/reactions.test.mjs closes a list whose close hides the opener and shows the trigger, which landed on the body before.npm run test:runtime(273) and eslint pass. The focus browser suites (chrome contracts, navigation, controls, threads, widgets, margin, anchors, drafts, reactions, aim, read state, interaction layer, send placement) fail 9 and pass 2173 with one write-watch error, as main (1e9fad2) does; all but one are main's own, the other istest_the_reading_page_keys_follow_the_user_into_the_panel, which fails on main in interleaved A/Bs, and the Resume journey passes.wt hook pre-mergefails onlytest_send_grows_thread_around_the_words[size2…], which fails on main. Evals (Claude Code and Codex, candidate against the merge base): widget-list-keeps-focus passes 5 of 6 candidate runs and 0 of 6 base runs; view-reveal-arrival, widget-controller-lifetime, widget-owned-context-keys and shared-contribution-actions pass 8 of 8 on the candidate and 7 of 8 on the base.