Repository navigation
Take focused and currentLocationIn out of the package API - #6927
Merged
Merged
Conversation
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
leaf-agent
approved these changes
Nov 24, 2026
This was referenced Nov 24, 2026
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]>
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.
One step of the package-interface redesign: functions that wrap a browser call leave the package API.
focusedandcurrentLocationIngo, 207 names to 205. Ten package modules read their own tree'sactiveElementinstead; the runtime keeps both.To weigh: a row reading
activeElementsubscribes to nothing, wherefocused()subscribed its reflection to each move, sokeyboard/scopes.jsnow marks the scopes around the node focus left and the one it reached. Without that, a recording'saria-keyshortcutsnever 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-readsis 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, andleaf-dev probe --baseby 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.