NEW 142757
calling element.focus() from -[WKWebView evaluateJavaScript:completionHandler:] does not show keyboard
https://bugs.webkit.org/show_bug.cgi?id=142757
Summary calling element.focus() from -[WKWebView evaluateJavaScript:completionHandler...
jacob berkman
Reported 2015-03-16 17:22:48 PDT
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'm guessing that wouldn'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've been looking forward to moving to WKWebView since last June but this behaviour has prevented us from making the switch.
Attachments
David Kilzer (:ddkilzer)
Comment 1 2015-03-17 07:24:21 PDT
Nick Quaranto
Comment 2 2015-05-12 17:26:02 PDT
Hey here, We've run into this same issue with WKWebView at Basecamp (https://basecamp.com) - we'd love for this or some equivalent to UIWebView's keyboardDisplayRequiresUserAction to be added in if possible. There doesn'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.
Emiel Mols
Comment 3 2015-09-29 06:54:37 PDT
I'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("WKContentView", "_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:", &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't change ;). Cheers!
pyanfield
Comment 4 2018-03-30 02:25:04 PDT
It's not resolved in the latest version iOS 11.
Kurt Revis
Comment 5 2022-08-15 15:45:59 PDT
I believe this was fixed in iOS 16 beta 6 by: https://bugs.webkit.org/show_bug.cgi?id=243416
Note You need to log in before you can comment on or make changes to this bug.