Skip to content

Keep a native control's Enter and Space from the scopes around it - #2567

Merged
max-sixty merged 5 commits into
mainfrom
agent-a60aea55a67a0afae
Oct 12, 2026
Merged

max-sixty merged 5 commits into
mainfrom
agent-a60aea55a67a0afae

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

In the keyboard register, native activation now belongs to the focused control the way text entry already did. A scope declared on a container could take Enter or Space from a link or button inside it: with a container scope binding Enter, Enter on a nested link ran the container's command and suppressed the browser's follow. #2558 hit this with the code block's Copy and worked around it with an at option on element scopes. That option is deleted here, since nothing else used it.

What changed (Lit follow-up review, item 64)

  • Behaviour. nativeActivationAt (keyboard/text-entry.js) names the platform's activation press at the focused control: Enter on a link; Enter or Space on a button, a button-type input or a <details> summary; Space on a checkbox or radio button. Unmodified presses only. No scope around the control runs a different Leaf command on that press. A row that only names the press, with nothing of its own to run, still names it: a link's Follow, or the versions menu's "open that version". A mode that owns the keyboard (Go-to, reactions, Page Map) still stands nearer, as before.
  • What speaks for the control. The control's own exact element scope, a page scope rooted at the focused control (a page disclosure's toggle, a thread title's reply), and a row whose control is the focused element all keep the press. A contextual alias on the control yields, as it yields to native editing, so dispatch and aria-keyshortcuts agree.
  • Plumbing. shadow().takes now receives the row and its scope at every call site (dispatch, lineOwner, reference reachability, the shortcut bar's lineRows), so the bar never shows a row that the dispatcher would withhold. A container's Enter that activation took makes no claim further out, so "On a link" still names Follow inside a code block.
  • Removed. Element scopes' at option (keyboard/scopes.js), its reading in command-reference.js, and its use in code-copy.js.
  • Choice. A plain button gets no "press" hint on the bar. Its Enter and Space are the most universal press there is, and a hint would spend one of the compact bar's two slots on every focused page button. Links get Follow because Enter and Space differ on a link. The new test asserts that the bar names nothing for a plain button rather than the container's command.

Hand-written source: +97 / −45 lines (text-entry.js, dispatch.js, scopes.js, command-reference.js, shortcut-bar.js, page.js, touch-controls.js, code-copy.js), most of it comments. Tests: +120 / −18.

Tests

  • tests/runtime/native-activation.test.mjs fails on main: Enter on a link inside a container ran the container's command. It checks a container scope binding Enter and Space around a link, a button and a disclosure button: the dispatcher's answer, the preserved default, and the row the bar names. It also checks that a contextual Enter/Space alias on a button yields in both dispatch and aria-keyshortcuts.
  • command-controls.test.mjs used Enter as an incidental context alias on a button. It now uses a digit, the only kind any widget declares.
  • test_each_sampled_focus_ring_is_shown_whole_in_its_surface failed on main since Declare a code block's Copy through the keyboard register #2558. Enter on a code block copies, and the copy control is out of the Tab sequence, so the sweep's sample of the copy control's ring is dropped.

Checks

  • npm run test:runtime passes.
  • I ran every render test whose body presses Enter or Space (288 functions), plus the reference, bar and disclosure cases in test_render_controls.py. Two tests still fail, and neither comes from this change:
    • test_primary_reader_revision_replaces_owner_without_losing_thread_draft fails the same way on main ("The page already has a Thread presentation" from dom-move.js).
    • test_code_copy_enter_leaves_nested_links_usable passes alone but failed under suite load, on its count of visible copy controls at presentation, not on keys.

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

max-sixty and others added 5 commits October 12, 2026 02:28
…round them

Native activation (Enter on a link, Enter or Space on a button) now belongs to the
focused control in the keyboard register, the way text entry already did. No scope
around the control runs a Leaf command on that press; a row that only names it, such
as a link's Follow, still names it on the shortcut bar. The code block's Copy no
longer needs element scopes' `at` option to leave a nested link its Enter, so `at`
on element scopes is deleted. A contextual alias of Enter or Space on a native button
is no longer projected into aria-keyshortcuts, since it no longer fires.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Since #2558, Enter on a code block copies it and its copy control stays out of the
Tab sequence, so the sweep's Enter route never focused the control and the test
failed on main. The control's ring is no longer a keyboard state to sample.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A scope rooted at the focused control speaks for it, so a page disclosure's toggle
keeps Enter and Space and its name on the bar, as before; a row clicking the
focused control is that control's press. A contextual alias on the control still
yields, so dispatch and aria-keyshortcuts agree. Native activation now also covers
a <summary> (Enter, Space) and a checkbox or radio button (Space), and page.js's
link scope reads the rule's link selector.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/assets/runtime/keyboard/AGENTS.md
@max-sixty
max-sixty merged commit 6b1210e into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-a60aea55a67a0afae branch October 12, 2026 10:13
max-sixty added a commit that referenced this pull request Oct 12, 2026
version.js conflicted only in its imports: this branch's rendering and
arrivals imports for continuity, and #2568's readingPaint for comparison
watchers. Both kept; the rest merged cleanly.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 12, 2026
The [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38235572771) also
failed the visual-part reaction test's assertion that Space clicks a
button on keydown. [#2567](#2567)
intentionally gave a focused button its native Space activation, which
clicks on keyup. This PR presses Space normally and keeps the test's
checks for the send, announcement, visual anchor, and replay.

The old assertion fails on current `main`; the corrected test passes
with the comparison case in a focused local run (`uv run pytest -q -n0`
with their two node IDs).

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