Skip to content

revise input api#48

Merged
zion-off merged 6 commits intomainfrom
revise-input-api
Feb 25, 2026
Merged

revise input api#48
zion-off merged 6 commits intomainfrom
revise-input-api

Conversation

@zion-off
Copy link
Owner

No description provided.

- Remove `layer` — stored but never used in dispatch
- Replace `when: 'mounted'` string enum with `global: boolean` — it was
  the only meaningful value, so a boolean is clearer
- Fix passthrough bug: keys in `passthrough` now `continue` to bubble up
  rather than silently returning, so tab navigation from capture-mode
  components actually reaches parent scopes
- Add `useGlobalKeybindings(bindings)` hook as the explicit replacement
  for the `when: 'mounted'` workaround; adds `registerGlobalKeybindings`
  to FocusStore internally
- Remove layer from KeybindingOptions reference
- Replace when:'mounted' with global:boolean in RegisteredKeybinding
- Add useGlobalKeybindings section with usage example
- Fix passthrough description to reflect actual bubble behaviour
- Update priority order list across core-concepts and architecture doc
Previously, global bindings were checked after the path walk, but capture
mode returned early inside the loop — so globals were never reached when a
capture-mode component (e.g. TextInput) had focus.

Restructured dispatch into three passes:
  1. Named bindings (walk focused node → root)
  2. Global bindings — checked before capture fires
  3. Capture mode (onKeypress) — only if no global binding matched

The trap boundary still prevents globals from escaping — capture fires
immediately on hitting the trap, then returns.
useGlobalKeybindings and the global flag on BindingEntry were solving
a problem better handled by registering bindings at the right scope.
Unhandled keys bubble naturally to ancestor scopes, so a root-level
useKeybindings call serves as an app-wide shortcut handler without
any special API.

- Delete useGlobalKeybindings hook
- Remove registerGlobalKeybindings from FocusStore
- Remove global flag from BindingEntry and RegisteredKeybinding
- Simplify dispatch: single pass, named bindings walk up the path,
  pendingCapture deferred until end, trap uses break not return
- Simplify useKeybindingRegistry: available is just the branch path
- Remove useGlobalKeybindings section from input.mdx
- Remove global field from RegisteredKeybinding reference
- Update priority order in core-concepts to reflect simplified dispatch
- Update architecture doc dispatch algorithm to match current implementation
@zion-off zion-off merged commit bfc1785 into main Feb 25, 2026
1 of 2 checks passed
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