Skip to content

Focus the text field when hs.ui.textPrompt opens - #393

Merged
cmsj merged 1 commit into
mainfrom
fix/textprompt-initial-focus
Nov 16, 2026
Merged

cmsj merged 1 commit into
mainfrom
fix/textprompt-initial-focus

Conversation

@cmsj

@cmsj cmsj commented Nov 16, 2026

Copy link
Copy Markdown
Owner

NSAlert doesn't make its accessory view the initial first responder, so when hs.ui.textPrompt() opened, the keyboard focus could start on a button (the Cancel button showed the focus ring) and typing went nowhere until you clicked into the field. This sets the text field as the alert window's initialFirstResponder, so it opens focused with the default text selected.

Related to #391. This does not fix the Escape/Tab report there, which I couldn't reproduce on a clean config (Escape cancelled in every path I tried, including show() called directly inside an hs.ipc request). This is a small improvement found while investigating it.

Testing

In an hs2vm VM, with real keystrokes:

  • The prompt opens with the field focused and sample selected. Typing typed + Return without clicking reports 0:typed.
  • Escape still cancels and reports 1:sample.

The Focus test prompt with a focus ring around the text field and "sample" selected

🤖 Generated with Claude Code

NSAlert doesn't make its accessory view the initial first responder, so
the keyboard focus could start on a button and typing went nowhere until
the user clicked into the field. Make the text field the window's initial
first responder, so it has focus with its default text selected.

Changelog-Fixed: `hs.ui.textPrompt()` now puts the keyboard focus in its text field when it opens, so you can type straight away
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge.

Summary

Sets the text field as the alert window's initialFirstResponder before hs.ui.textPrompt() opens.

  • Text prompts open with the input field ready for typing.

Reviews (1) · Last reviewed commit: "Focus the text field when hs.ui.textProm..." · Reviewed by Greptile

@cmsj
cmsj merged commit 54a6061 into main Nov 16, 2026
4 checks passed
@cmsj
cmsj deleted the fix/textprompt-initial-focus branch November 16, 2026 14:13
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