Skip to content

Fix search field not visibly taking focus when the search window opens#6

Open
MiMoHo wants to merge 1 commit into
haad:masterfrom
MiMoHo:search-field-focus
Open

Fix search field not visibly taking focus when the search window opens#6
MiMoHo wants to merge 1 commit into
haad:masterfrom
MiMoHo:search-field-focus

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Opening the search window (Shift-Cmd-B) did not visibly focus the search field: no blinking caret, the field looked inactive — even though keystrokes actually reached it and text appeared once you typed.

Cause & fix

The window is opened from a global hotkey while another app is active. App activation is asynchronous on modern macOS, so the makeFirstResponder: call inside showSearchWindow runs before the window can actually become key, and the field editor/caret is never installed. The fix focuses the field from windowDidBecomeKey: (AppController is already the window's delegate), i.e. at the moment the window has genuinely taken key status. The guard on notification.object == searchWindow keeps the bezel's behavior unchanged.

Testing

clang -fsyntax-only clean versus master. No full local xcodebuild available on this machine — to verify: focus any other app, hit Shift-Cmd-B, and the caret should now blink in the search field immediately.

🤖 Generated with Claude Code

The search window is opened from a global hotkey while another app is
active. App activation is asynchronous on modern macOS, so the
makeFirstResponder: call in showSearchWindow ran before the window
could become key: typing reached the field, but no caret appeared and
the field looked unfocused. Focus the field from windowDidBecomeKey:
instead, once the window has actually taken key status.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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