1

I've been experiencing a strange bug in Safari iOS8. On the login page of our website, if you click on the username textbox, the keyboard shows and then your focus is moved automatically to the password textbox.

After deleting a lot of code to try and find the cause, I have finally been able to create a simple reproduction.

Essentially all you need to do is register a "touchstart" event on a parent container (like a form). Then you focus the textbox inside the form using javascript.

Once the user goes to click the textbox, the above bug happens and their click is repeated after the page moves up.

The device must also be in landscape mode to force the page to scroll when the keyboard appears.

You can see a jsfiddle of it here: http://jsfiddle.net/9xnfpLrd/22/

document.getElementById("myform").addEventListener('touchstart', function(e) {});
document.getElementById("myfirstelement").focus();

My Safari version is the following:

Mozilla/5.0 (iPad; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B410 Safari/600.1.4

I thought I would post this all here in the hopes that someone who also has this issue doesn't have to spend 2 days figuring this all out.

Eddie Fletcher
  • 2,823
  • 2
  • 21
  • 23
  • I was able to reproduce this on our own website. Same exact behavior happens. So are you saying that not focusing will work around this bug? – Sean Larkin Dec 11 '14 at 18:07
  • In the end we removed the touchstart event handler as most of the mobile browsers seem to respond to the default events anyway. You need both the touchstart and the focus call to reproduce this behaviour. If you remove either one then everything works as expected. – Eddie Fletcher Dec 11 '14 at 19:52
  • Yes, I don't believe I have found a way to trigger the iPad keyboard to open except through user interaction. – Sean Larkin Dec 11 '14 at 19:53
  • You are right, currently this is the case, see http://stackoverflow.com/questions/26146252/in-ios8-using-focus-will-show-virtual-keyboard-and-scroll-page-after-touch – Eddie Fletcher Dec 11 '14 at 20:00

0 Answers0