Skip to content

Take focused and currentLocationIn out of the package API - #6927

Merged
max-sixty merged 3 commits into
mainfrom
agent-a4aa62f61c28f82ce
Nov 24, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-a4aa62f61c28f82ce

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

One step of the package-interface redesign: functions that wrap a browser call leave the package API. focused and currentLocationIn go, 207 names to 205. Ten package modules read their own tree's activeElement instead; the runtime keeps both.

To weigh: a row reading activeElement subscribes to nothing, where focused() subscribed its reflection to each move, so keyboard/scopes.js now marks the scopes around the node focus left and the one it reached. Without that, a recording's aria-keyshortcuts never gained its zoom keys as focus entered its timeline. The sites avoid :focus-within, which Chromium stops matching while the window is in the background, when revisions arrive. architecture/current-location-reads is off for packages. A held label press and a pressed tab panel now read as the browser has them.

Left in, each carrying behaviour: focusDestination, onCurrentLocation, holdFocus, placeOf, retainUserIntent, onUserInput.

Ran: pre-commit, pnpm run check, browser tests by node id, and leaf-dev probe --base by keyboard on the board, tabs, draft, option list, deck, recording and diff filter in Chromium and Firefox, where base and head agree. A fresh agent's review found a slotted control and a dropped node, both fixed.

This was written by Claude Code on behalf of max-sixty

One step of the package-interface redesign: functions that wrap a
browser call leave the package API. `focused` and `currentLocationIn`
go, 221 names to 219. Ten package modules read their own tree's
`activeElement` instead, with `contains` for a scope; the runtime keeps
both functions, and the render gate's probes read `focused` from
check-api.js.

A row reading `activeElement` subscribes to nothing, where `focused()`
subscribed its reflection to each move, so keyboard/scopes.js now marks
the scopes around the node focus left and the one it reached, and those
around the left node as it stood when the user arrived. The sites avoid
`:focus` and `:focus-within`, which Chromium stops matching while the
window lacks system focus, when revisions arrive.
`architecture/current-location-reads` is off for packages. A held label
press and a pressed tab panel now read as the browser has them.

Left in, each carrying behaviour a caller depends on: focusDestination,
onCurrentLocation, holdFocus, placeOf, retainUserIntent and onUserInput.
# Conflicts:
#	browser/runtime/check-api.js
#	browser/runtime/widget-api.js
#	eslint.config.mjs
#	packages/file-editor/widgets/lf-file-editor.js
@max-sixty
max-sixty merged commit b9cea93 into main Nov 24, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-a4aa62f61c28f82ce branch November 24, 2026 01:49
leaf-agent added a commit that referenced this pull request Nov 24, 2026
Each file tree row the user focused kept the tree's shared command
declaration. That declaration's `when` reads whether *any* row in the
tree holds focus. Since #6927 replaced `focused()` with a read of the
shadow root's `activeElement`, Leaf rereads a scope's rows only around
the node focus left and the node it reached (`markAroundMove` in
`keyboard/scopes.js`). That matches the contract in `module-input.md`:
rows are reread "whenever focus moves into, out of or within the scope".
So rows focused earlier kept naming the keys as they stood when focus
left them, and a forced repaint changed their `aria-keyshortcuts`.

With this change, only the focused row carries the declaration. The
widget's `onCurrentLocation` handler withdraws it from the tree row
focus leaves (`lfCommands = null` plus `lf-commands`). The host's own
declaration and the focused row's keys stay as they were, so Enter,
Space and the arrows reach a row exactly as before. The fix stays in the
package: #6927's intent, that packages ask the browser where focus is,
holds without a new core mechanism.

Verification: the `[file-tree]`, `[file-tree-input]` and
`[deploy-config]` cases of
`tests/journeys/test_render_navigation.py::test_presses_and_fills_leave_no_element_naming_stale_keys`
fail on `main` and pass on this branch. The file tree's pointer and
keyboard tests
(`test_file_tree_opens_current_diff_files_by_pointer_and_keyboard`,
`test_file_tree_lands_at_the_file_start_after_reading_down`,
`test_a_file_tree_opens_each_file_the_editor_holds`, and the two
`test_file_tree_*` browser tests) also pass. The browser type check and
pre-commit's eslint/oxfmt pass too.

Closes #7020 — automated triage

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants