Repository navigation
Focus the text field when hs.ui.textPrompt opens - #393
Merged
Merged
Conversation
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>
Contributor
[Low impact] This PR appears safe to merge. SummarySets the text field as the alert window's
Reviews (1) · Last reviewed commit: "Focus the text field when hs.ui.textProm..." · Reviewed by Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NSAlertdoesn't make its accessory view the initial first responder, so whenhs.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'sinitialFirstResponder, 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:
sampleselected. Typingtyped+ Return without clicking reports0:typed.1:sample.🤖 Generated with Claude Code