tao icon indicating copy to clipboard operation
tao copied to clipboard

macOS WebView does not respond to keyboard events until clicked

Open kofigumbs opened this issue 4 years ago • 0 comments

Describe the bug

Launching a Tauri app on macOS does not automatically "focus" the webview, so keyboard events are ignored until I explicitly click on the window. I'm using a Tauri project to demonstrate the issue, but the actual code at fault lives in tao.

To Reproduce

Steps to reproduce the behavior:

  1. Clone https://github.com/kofigumbs/tauri-macos-first-responder
  2. cd src-tauri && cargo run (or cargo tauri dev)
  3. Press any keyboard key to try and interact with the app

Expected behavior

The app should be immediately responsive to keyboard events without requiring the user to click. I worked around this issue by explicitly calling makeFirstResponder_. You can run the above with --features make-first-responder to verify.

Additional context

It looks like tao used to use makeFirstResponder_, but switched to initialResponder in https://github.com/tauri-apps/tao/commit/45aacd840752bc1af07677da44af4911dbd701c8. Apple's API docs suggest that that is the right approach, so I'm not sure why it doesn't work. If the path forward is as simple as reverting https://github.com/tauri-apps/tao/commit/45aacd840752bc1af07677da44af4911dbd701c8, I'd be happy to do the leg work to submit the PR.

kofigumbs avatar Sep 21 '21 01:09 kofigumbs