Bug 229600 - WKWebView: cannot become first responder using focus() in JavaScript or native becomeFirstResponder() method
Summary: WKWebView: cannot become first responder using focus() in JavaScript or nativ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: Safari 14
Hardware: iPhone / iPad iOS 13
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-08-26 21:45 PDT by Daohan Chong
Modified: 2021-09-02 21:46 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daohan Chong 2021-08-26 21:45:35 PDT
For example, if we'd like to build a web based text editor, we'd like to automatically focus on the text input area in `UIViewController.viewDidAppear`.

However, we cannot build behavior like this using public API. For example, all these won't work:

- Calling `htmlElement.focus()` does nothing.
- `WKWebView.becomeFirstResponder()`

The community is trying to explore how to work around this missing feature: https://stackoverflow.com/questions/32449870/programmatically-focus-on-a-form-in-a-webview-wkwebview/48623286#48623286

This can be reproduced on iOS 13 to iOS 15 beta.
Comment 1 Radar WebKit Bug Importer 2021-09-02 21:46:18 PDT
<rdar://problem/82708554>