<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>227364</bug_id>
          
          <creation_ts>2021-06-24 11:05:08 -0700</creation_ts>
          <short_desc>iOS WKWebView findString not selecting and scrolling</short_desc>
          <delta_ts>2021-07-01 11:06:18 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit2</component>
          <version>Other</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 14</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=203872</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>zero.griffin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>beidson</cc>
    
    <cc>kkinnunen</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1772366</commentid>
    <comment_count>0</comment_count>
    <who name="">zero.griffin</who>
    <bug_when>2021-06-24 11:05:08 -0700</bug_when>
    <thetext>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 &quot;Find on Page&quot;, 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&apos;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(&quot;hello world&quot;) { result in
    print(result.matchFound) // true
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1772422</commentid>
    <comment_count>1</comment_count>
    <who name="Wenson Hsieh">wenson_hsieh</who>
    <bug_when>2021-06-24 12:48:47 -0700</bug_when>
    <thetext>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));
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1774170</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-07-01 11:06:18 -0700</bug_when>
    <thetext>&lt;rdar://problem/80034358&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>