Skip to content

Add captureTab host prop for terminal-style controls #36

Closed

Description

@monotykamary

Problem

GPUI maps Tab and Shift+Tab to FocusNext and FocusPrevious. A focused host div that implements terminal or editor keyboard handling receives keyDown, but the native focus action then moves focus to another control. GPUIX key events do not expose a way for application JavaScript to stop that action, so refocusing from React is racy and subsequent keystrokes can reach the wrong control.

Reproduction

<div autoFocus tabIndex={0} onKeyDown={(event) => terminal.write(event)}>
  Terminal
</div>
<div tabIndex={0}>Outside</div>

After simulateKeystrokes("tab a"), a is dispatched to Outside rather than the terminal.

Proposed API

Add an optional universal captureTab host prop:

<div tabIndex={0} captureTab onKeyDown={(event) => terminal.write(event)} />

When enabled, the native host element installs handlers for FocusNext and FocusPrevious. GPUI actions stop propagating when a handler does not explicitly propagate, so Tab and Shift+Tab remain on the focused element while its existing keyDown listener still receives both keys.

The implementation touches:

  • packages/react/src/reconciler/host-config.ts to forward the prop
  • packages/react/src/types/host.ts for typing
  • packages/native/src/renderer.rs for the two action handlers
  • the native floating-controls tests for Tab and Shift+Tab coverage
  • README focus documentation and patch changesets for @gpuix/react and @gpuix/native

Validation

I have a source patch against GPUIX 0.6.0. The focused regression passes on macOS ARM64, all 14 floating-controls tests pass, and an application integration test confirms Tab, Shift+Tab, continued terminal typing, and fullscreen PTY resize behavior.

May I open a pull request with this implementation?

Activity

  1. added a commit that references this issue on Sep 1, 2026
    a24b4a4
  2. added 3 commits that reference this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions