Repository navigation
fix: close the file tree's search on row activation and on Enter after the Trees 1.0.0 bump - #7488
leaf-agent wants to merge 2 commits into
Conversation
…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
|
@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
|
…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]>
|
Fixed in 9e63b54: the search field's Enter handler now returns early on |
|
The red Adding Separately, |
leaf-agent
left a comment
There was a problem hiding this comment.
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.jsto the test's allowed set, with the reason that Trees answers Enter in its own field, and adjust the rule inbrowser/runtime/dom/keyboard/AGENTS.mdthat every key in a package widget is declared. This is the smallest change. Its cost is that the command reference andaria-keyshortcutsdon'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.chooseon 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" inAGENTS.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.
@pierre/trees1.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:computeFileTreeRowClickPlannow returnscloseSearch: 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"), andtest_file_tree_opens_current_diff_files_by_pointer_and_keyboardasserts 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:closeSearch().lf-file-treehandles 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
mainatcd2495ac7, where[patch]stops at line 698 because the field still readsimporter. Both pass on this branch. The other file-tree tests also pass: the browser tests intest_render_files.pyandtest_render_diff_controls.py, andtests/runtime/lf-file-tree-story.test.mjs. #7410 fixed the other two journeys in #7402, so this closes it.Closes #7402 — automated triage