vercel-labs / vercel-labs/native
Bug: Autofocus is lost when a deferred GPU window is first shown on macOS
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:
- Mount a
textareawithautofocus = truein the initial layout. - Launch the app with a deferred GPU window.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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