2

I'm building an app in HTML5 and Javascript using WKWebView.

I have a very plain text input that I want to call focus() on manually via javascript. It does work, the keyboard pops up and there is a cursor in the input however the iOS keyboard is very laggy when typing/deleting the first character. It takes over a second for the character to appear and for the keyboard to become interactive again.

Does anyone have any idea on how what the problem might be?


Alex Fox
  • 1,175
  • 2
  • 15
  • 27
  • There is [a bug related to `WKWebView` and `element.focus()`](https://bugs.webkit.org/show_bug.cgi?id=142757) that might be interfering – jandersen Feb 17 '16 at 21:53

2 Answers2

0

Try using click() instead of focus(). Both will give you the same response provided u dont have any events attached to onclick of the text box.

Ajmal E S
  • 57
  • 4
  • 1
    unfortunately using click() doesn't improve the situation! – Alex Fox Aug 11 '15 at 16:43
  • Can u try giving a default value after focusing on the field? – Ajmal E S Aug 11 '15 at 17:07
  • If it helps anyone: I had a bug where the voice input would fill in the text again after the focus on the input was lost & manually reset with JS again by calling .focus() -> using .click() instead fixed this bug – Marc Borni Feb 21 '19 at 18:16
0

We had a similar problem in an AngularJS app with WKWebview and we solved it by using ng-click event instead of ng-focus (only on iOS).

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
kris_IV
  • 2,396
  • 21
  • 42