<?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>142757</bug_id>
          
          <creation_ts>2015-03-16 17:22:48 -0700</creation_ts>
          <short_desc>calling element.focus() from -[WKWebView evaluateJavaScript:completionHandler:] does not show keyboard</short_desc>
          <delta_ts>2022-08-15 15:45:59 -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>WebKit API</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 8.2</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <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 name="jacob berkman">jberkman</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cathyxz</cc>
    
    <cc>craig</cc>
    
    <cc>dbates</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>developer</cc>
    
    <cc>emiel.mols</cc>
    
    <cc>enrica</cc>
    
    <cc>james</cc>
    
    <cc>jonathan</cc>
    
    <cc>krevis</cc>
    
    <cc>mikkel_500</cc>
    
    <cc>mitz</cc>
    
    <cc>nick</cc>
    
    <cc>onderceylan</cc>
    
    <cc>pyanfield</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1077660</commentid>
    <comment_count>0</comment_count>
    <who name="jacob berkman">jberkman</who>
    <bug_when>2015-03-16 17:22:48 -0700</bug_when>
    <thetext>See the fix in https://bugs.webkit.org/show_bug.cgi?id=132974

Our app embeds an html page, and has an interface similar to Keynote, in that tapping on an element presents a wireframe, and double-tapping begins editing. We handle the double-tap gesture my making a call to -[WKWebView evaluateJavaScript:completionHandler:], which ends up calling element.focus() on the appropriate node.

I suspect that setting m_userIsInteracting = true in WebPage::runJavaScriptInMainFrame() would work around this in some cases, but I&apos;m guessing that wouldn&apos;t work if we ended up calling .focus() in a timeout handler.

Are there any other mechanisms that could be done to allow element focusing from JS? Maybe require interaction only while the page is loading or something? We&apos;ve been looking forward to moving to WKWebView since last June but this behaviour has prevented us from making the switch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1077879</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2015-03-17 07:24:21 -0700</bug_when>
    <thetext>&lt;rdar://problem/17355265&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1094326</commentid>
    <comment_count>2</comment_count>
    <who name="Nick Quaranto">nick</who>
    <bug_when>2015-05-12 17:26:02 -0700</bug_when>
    <thetext>Hey here,

We&apos;ve run into this same issue with WKWebView at Basecamp (https://basecamp.com) - we&apos;d love for this or some equivalent to UIWebView&apos;s keyboardDisplayRequiresUserAction to be added in if possible.

There doesn&apos;t seem to be any real workarounds so this really impacts our user experience when we want to focus on a web form or contenteditable element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1129239</commentid>
    <comment_count>3</comment_count>
    <who name="Emiel Mols">emiel.mols</who>
    <bug_when>2015-09-29 06:54:37 -0700</bug_when>
    <thetext>I&apos;ve managed to work-around this on at least iOS 9 by swizzling _startAssistingNode:userIsInteracting:blurPreviousNode:userObject on WKContentView and overriding the userIsInteracting value:

Pseudo code:

    swizzle_intercept(&quot;WKContentView&quot;, &quot;_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:&quot;, &amp;hackAssist);

    void hackAssist (id self, SEL _cmd, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
        ((void (*)(id,SEL,void*,BOOL,BOOL,id))swizzle_interceptee(hackAssist))(self, _cmd, arg0, TRUE, arg2, arg3);
    }

Use it to your advantage while the API doesn&apos;t change ;). Cheers!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410570</commentid>
    <comment_count>4</comment_count>
    <who name="pyanfield">pyanfield</who>
    <bug_when>2018-03-30 02:25:04 -0700</bug_when>
    <thetext>It&apos;s not resolved in the latest version iOS 11.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1891477</commentid>
    <comment_count>5</comment_count>
    <who name="Kurt Revis">krevis</who>
    <bug_when>2022-08-15 15:45:59 -0700</bug_when>
    <thetext>I believe this was fixed in iOS 16 beta 6 by:
https://bugs.webkit.org/show_bug.cgi?id=243416</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>