vercel-labs / vercel-labs/native

Bug: Autofocus is lost when a deferred GPU window is first shown on macOS

Open
#166 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Zig
Stars
7.7k
Forks
314
Avg merge
5h
Merged PRs (30d)
13

Description

On macOS, an autofocus widget mounted inside a GPU window may not receive keyboard focus when the window uses .on_first_present.

Reproduction:

  1. Mount a textarea with autofocus = true in the initial layout.
  2. Launch the app with a deferred GPU window.
  3. After the first frame appears, type without clicking the textarea.

Expected: the textarea receives the input.

Actual: AXFocusedUIElement is the window, not the textarea.

The autofocus request runs while the window is still ordered out. Later, showDeferredWindowIfPending calls makeKeyAndOrderFront, but does not restore the requested first responder. Because autofocus is edge-triggered, subsequent rebuilds do not retry it.

Suggested fix: retain the pending focused NSView for deferred windows and call makeFirstResponder after makeKeyAndOrderFront. Please add a macOS regression test covering autofocus through the initial deferred-show transition.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the deferred-window path around showDeferredWindowIfPending and the autofocus request for the initial layout. Add a macOS regression test covering autofocus when a GPU window is first shown with .on_first_present. Done means the textarea receives keyboard input without a click after the first frame appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, zig
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.