Skip to content

✨ focus: navigate focusable host elements - #23

Closed
cowboyd wants to merge 1 commit into
tree-renderfrom
tree-focus
Closed

cowboyd wants to merge 1 commit into
tree-renderfrom
tree-focus

Conversation

@cowboyd

@cowboyd cowboyd commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Interactive terminal controls need focus, but focus is not inherently a keyboard concept and should not be reimplemented by every input element or framework adapter. A semantic Focus API provides one source of truth for the active node and lets controls declare focusability without knowing how users will navigate between them. Keeping this state in the middleware tree also makes focus available to custom element behavior such as layout, styling, and event handling.

Focus must remain valid as the Host tree changes. The first attached focusable element can become active automatically, traversal follows Host render order in both directions, and removing the focused subtree selects an appropriate replacement or returns to the host root. Focus changes also invalidate rendering so visual focus state is not delayed until another mutation.

This PR adds FocusApi, focus installation, focusability, direct focus assignment, and wrapping depth-first forward and reverse navigation. It handles initial focus, rejects invalid targets, repairs focus during subtree removal, and requests rendering when focus changes.

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

commit: 472a333

@cowboyd

cowboyd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

closing out in favor of a DOM based substrate. See #37

@cowboyd cowboyd closed this Oct 23, 2026
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.

1 participant