| Summary: | iOS WKWebView findString not selecting and scrolling | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | zero.griffin |
| Component: | WebKit2 | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Normal | CC: | beidson, kkinnunen, thorton, webkit-bug-importer, wenson_hsieh |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Other | ||
| Hardware: | iPhone / iPad | ||
| OS: | iOS 14 | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=203872 | ||
FWIW, the documentation does suggest that the matching range ought to be selected and scrolled into view: ``` /* @abstract Searches the page contents for the given string. @param string The string to search for. @param configuration A set of options configuring the search. @param completionHandler A block to invoke when the search completes. @discussion If the WKFindConfiguration is nil, all of the default WKFindConfiguration values will be used. A match found by the search is selected and the page is scrolled to reveal the selection. The completion handler is called after the search completes. */ - (void)findString:(NSString *)string withConfiguration:(nullable WKFindConfiguration *)configuration completionHandler:(void (^)(WKFindResult *result))completionHandler NS_REFINED_FOR_SWIFT WK_API_AVAILABLE(macos(11.0), ios(14.0)); ``` |
Since iOS 14 WebKit supports findString, but there is no documentation whatsoever yet. However on the WWDC Sessions Discover WKWebView enhancements they mention that is a basic functionality for "Find on Page", where you can find a string and the WebView will select it and scroll to center it. It seems very easy to use and to be finding the string as I get a result of matchFound true, but there is no selection and there is no scrolling. Maybe I'm missing something? This is the code I have tried: let webView = WKWebView() // ... // after loading a website with the desired string on it. // ... webView.find("hello world") { result in print(result.matchFound) // true }