Skip to content

fix: close the file tree's search on row activation and on Enter after the Trees 1.0.0 bump - #7488

Open
leaf-agent wants to merge 2 commits into
mainfrom
fix/issue-7402-file-tree
Open

leaf-agent wants to merge 2 commits into
mainfrom
fix/issue-7402-file-tree

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

@pierre/trees 1.0.0, from the Dependabot group in #7298, changed two search behaviours of the file tree on purpose. Pressing a row no longer closes the search: computeFileTreeRowClickPlan now returns closeSearch: false. Enter in the search field now only selects the focused match, so the field keeps its text and focus. In 1.0.0-beta.6, Enter also closed the search and moved focus to the row. lf-file-tree's header still promises the beta's behaviour ("Search clears on blur or activation. Enter in search chooses a row"), and test_file_tree_opens_current_diff_files_by_pointer_and_keyboard asserts it. The bump meant to update the library, not to change how the file tree's search works, so this keeps Leaf's behaviour and adapts to the new library:

  • A row's activation calls Trees' public closeSearch().
  • lf-file-tree handles a plain Enter in the search field itself. It selects the focused match and focuses that row. Focusing the row blurs the field, and Trees' own blur handler closes the search. An Enter that confirms an IME candidate (isComposing) is left to the field, so search stays open; the journey checks this.

A reader sees the same behaviour as before the bump. Both cases of the journey fail on main at cd2495ac7, where [patch] stops at line 698 because the field still reads importer. Both pass on this branch. The other file-tree tests also pass: the browser tests in test_render_files.py and test_render_diff_controls.py, and tests/runtime/lf-file-tree-story.test.mjs. #7410 fixed the other two journeys in #7402, so this closes it.

Closes #7402 — automated triage

…re Trees 1.0.0

@pierre/trees 1.0.0 (#7298) keeps its search open when a row is pressed and
when Enter is pressed in the search field, where 1.0.0-beta.6 closed it and,
on Enter, moved focus to the chosen row. lf-file-tree's header still promised
the beta's behaviour and the file tree journey asserted it.

Activation now calls Trees' public closeSearch(), and lf-file-tree handles a
plain Enter in the search field itself: it selects the focused match and
focuses its row, whose blur of the field closes Trees' search. Behaviour a
reader sees is the same as before the bump.

Closes #7402
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The search field's capture keydown handler treats Enter during IME composition as row selection. With a focused match, an unmodified Enter where isComposing is true calls preventDefault and focusDestination, blurring the field while the user is confirming a candidate. Please exclude composing key events and check that confirming a candidate leaves the search open.

This was written by Codex on behalf of max-sixty

…ME candidate

The search field's Enter handler selected the focused match and focused its
row even while composing, which blurred the field and closed search as the
user confirmed a candidate. It now ignores composing key events, and the file
tree journey checks that a composing Enter keeps the field's text and focus.

Co-Authored-By: Claude <[email protected]>
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Fixed in 9e63b54: the search field's Enter handler now returns early on event.isComposing, so confirming a candidate leaves the field's text, focus and search open. test_file_tree_opens_current_diff_files_by_pointer_and_keyboard now dispatches a composing Enter on a focused match and asserts the field keeps its value and focus. That check fails without the guard and passes with it.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

The red test on 932b5504a comes from this PR's change. test_the_register_is_the_only_way_a_key_enters_the_runtime (tests/model/test_interact_layer.py) pins every keydown listener in the runtime and in package widgets. The new capture listener in lf-file-tree.js is one it doesn't list (lf-file-tree.js:257 in the failing run). The IME commit 9e63b5452 keeps that listener, so its head will fail the same assertion.

Adding lf-file-tree.js to the test's allowed set would undo what the test protects: a key bound outside the register is one no Leaf surface can promise. The repair belongs in the widget, and one constraint shapes it. In search, Trees' own onKeyDown handles Enter by calling selectOnlyPath, then preventDefault and stopPropagation, all inside its shadow root, and it doesn't check isComposing there. So a register row on the search field (lfCommands, as the rows already use) wouldn't hear Enter through the root listener. The dispatcher's press already skips composing keys, so a register route would also cover the IME case on its own. The open question is how Leaf reaches the key before Trees stops it. Leaf's base/field-keys.js / readLeavingKeys capture path is the likely place to look, since that's how a Leaf field's keys reach the register.

Separately, tests/smoke/test_smoke.py::test_reading_keys_follow_a_submitted_comment_s_viewport failed in the same job ("Locator expected to be focused"). It doesn't involve the file tree, and I haven't checked it against main.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head still fails test_the_register_is_the_only_way_a_key_enters_the_runtime: the capture keydown listener added to lf-file-tree.js is one the test doesn't name. It can't move into the register with what Leaf has now. Trees answers Enter in its search field and calls stopPropagation inside its shadow root, so the dispatcher's root listener never hears it, and keepFieldKeys/readLeavingKeys only cover fields Leaf builds.

I tried a widget-local route that drops the listener: react to the selection Trees makes on Enter (onSelectionChange) when the search field has focus. It fails the journey at the row.click() step, because a pointer press on a row during search also selects while the field keeps focus. Telling the two apart takes a pointer flag, a composition flag and a flag for Leaf's own selectOnly of current. That is more machinery than the listener it replaces, and Enter would still be answered outside the register. So I didn't push it.

That leaves two routes, and both are the maintainer's call. @max-sixty, which do you want?

  • Name the listener as an exception. Add lf-file-tree.js to the test's allowed set, with the reason that Trees answers Enter in its own field, and adjust the rule in browser/runtime/dom/keyboard/AGENTS.md that every key in a package widget is declared. This is the smallest change. Its cost is that the command reference and aria-keyshortcuts don't list this Enter, the same as they don't list Trees' other search keys today.
  • Give the dispatcher a capture route for keys typed into a field in a widget's shadow stage. A widget could then declare files.choose on the search field, and the dispatcher's existing composition skip would handle the IME case. This adds a mechanism to the core ("Complicating the core" in AGENTS.md) that other widgets wrapping a library field could also use.

The tests/smoke/test_smoke.py::test_reading_keys_follow_a_submitted_comment_s_viewport failure in the earlier test run is still unchecked against main. Every recent ci push run on main was cancelled.

This branch has not been deployed

No deployments
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.

Shot divider and chart pointer journeys fail since #7298 bumped Web Awesome and Plot

2 participants